Drawing variable circles with an Arduino Uno and a Nokia 5110 LCD

I’m still trying to catch up on some of my new toys that I bought/got around Christmas time. I know, I’m four months behind! One of those gadgets was a Nokia 5110 LCD screen, and this thing is fun! It looks like something they used to use in old Nokia cell phones, and it works great for a monochrome, low resolution display.

I’m driving it with an Arduino Uno board. At first, to make sure I understood how to use it, I watched InterlinkKnight’s Youtube tutorial, which you also should check out. It was very clear, highly informative, and really well put together.

After watching the tutorial, and loading the library and his sketches, I then set out to make my own. I noticed a couple of things that were noteworthy for the new user, so I thought I’d share them here.

First, you need the library. You can get it here: https://github.com/olikraus/U8glib_Arduino

Just unzip the library, and put it in your Arduino library folder (unzipped, of course). For me, on my Ubuntu Linux machine, that was in /home/alaskalinuxuser/Arduino/libraries/, where I just dropped off the unzipped folder from U8. If you don’t put this in your Arduino libraries, it can’t find the referenced include file, and this wont work.

Then I made my own sketch:

/*
This is an example on how to use the display known as Nokia 5110 SPI with PCD8544 driver using the U8GLIB library.

Nokia 5110 SPI display pins for Arduino Uno/Nano:
* RST = 8
* CE = 10
* DC = 9
* DIN = 11
* CLK = 13
* VCC = 5V
* BL = 3.3V
* GND = GROUND

We use this library: https://github.com/olikraus/U8glib_Arduino

User Reference Manual: https://github.com/olikraus/u8glib/wiki/userreference

List of fonts: https://github.com/olikraus/u8glib/wiki/fontsize

Sketch Originally made by: InterlinkKnight
This sketch was featured on his video tutorial for this display: https://www.youtube.com/watch?v=1ZvY_lb6BoU
Last modification: 11/22/2017

Sketch modified by alaskalinuxuser
Last modification: 04/02/2019
*/

#include “U8glib.h” // Include U8glib library
// Create display and set pins:
U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // (CLK=13, DIN=11, CE=10, DC=9, RST=8)

int Variable1; // Create a variable to have something dynamic to show on the display
int fadeAmount = 1; // how many points to change by

void setup(void) // Start of setup
{

// Select a font:
u8g.setFont(u8g_font_profont12);

// Change display orientation:
//u8g.setRot90();
u8g.setRot180();
//u8g.setRot270();

} // End of setup

void loop(void) // Start of loop
{
// wait for 25 milliseconds to see the dimming effect
delay(25);

// change the brightness for next time through the loop:
Variable1 = Variable1 + fadeAmount;

// reverse the direction of the fading at the ends of the fade:
if (Variable1 <= 0 || Variable1 >= 45) {
fadeAmount = -fadeAmount;
}

u8g.firstPage(); // Beginning of the picture loop
do // Include all you want to show on the display:
{
u8g.drawCircle(41, 21, Variable1, U8G_DRAW_ALL); // Draw a circle (x,y,radius,option)

u8g.drawRFrame(59, 10, 25, 13, 3); // Draw a rounded square (x,y,width,height,radius)

// Variable with left text alignment:
u8g.setPrintPos(63, 20); // (x,y)
u8g.print(Variable1); // Value to print
} while(u8g.nextPage()); // End of the picture loop

} // End of loop

The key part of what I was playing with, was using a variable to set the circle size. Every run of the loop, after a slight delay, the circle is increased or decreased in size to make it grow or shrink on the screen. This makes a very nice “pulse” effect. Most of the code here was originally in InterlinkKnight’s sketch, I just modified it for my use, and added a variable changer.

Another thing I noticed was the back lighting. On my Nokia 5110, it is labeled as “BL” which means you apply voltage to it to illuminate the back lighting of the screen. In his tutorial, he rightly mentioned that you could use 5 volts here, which works great, but I found it to be obnoxiously bright. Instead, I used the 3.3 volt output from the Uno, and that was much better on the eyes. The screen will work without the back lighting, but then you need ample light to view it.

I’m seeing some fun potential with this screen!

Linux – keep it simple.

Android meets Arduino!

As you guys know, I don’t really do “product reviews”. But if I find a handy tool, and use it, then it is fun to share that info with others. One such tool is Bluino Loader, an Android app that lets you create Arduino files, upload them to your boards, and even monitor the serial connection over USB. It’s pretty handy!

As with any “code from your phone app”, it is a bit tedious to type a lot of code with the Android keyboard. So I don’t use this app a lot when it comes time to create code. One of the big things that I like to do with it, though, is to monitor the serial output over a USB OTG cable.

Using the OTG cable, I can hook the Arduino Uno board directly to the phone, which also powers the board. Then I can open up Bluino Loader and click the icon at the top to monitor the serial connection. It can’t get much simpler than that. Within seconds I have serial data coming in and being displayed in the terminal. I even used it to test out the 433 MHz transmit and receive functions from my last test project. Worked like a charm!

Linux – keep it simple.

Radio check sat! Using 433MHz transmitter and receiver with Uno board….

transmitAndReceive

Now that picoEngine has reached version 1.0, I’m ready to work on a few other projects. Namely some electronic ones. Since Christmas, I’ve been holding on to a few Arduino Uno boards, and a pile of stuff for them. So, I broke out a few parts.

IMG_20190326_132946

I decided to start with the 433MHz transmitter and receiver.

There were several guides online, and I stole some code from them. I like starting any project with a known good source before stepping out into something I made, to make sure the hardware/software is set up properly. It was a great tutorial, and it worked.

However, there was one unexpected drawback: range. I knew these little transmitters and receivers were weak, but I didn’t realize that they literally only transmit an inch! As you can see in the picture, the Uno boards are almost touching just to transmit the data back and forth. I had purchased a few of these (three sets for myself, and two for my brother) with the intention of doing a few fun projects. Unfortunately, these wont transmit across my desk, let alone the parking lot, so I’ll need something else to work with.

But, these are still a fun learning tool, just a little lacking in the range department! Here are the sketches I used, keep in mind, you need the “radiohead library” installed in your IDE to make this work.

Transmitter:

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;

void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println(“init failed”);
}

void loop()
{
const char *msg = “Hi World!”;
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
}

Receiver:

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver;

void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println(“init failed”);
}

void loop()
{
uint8_t buf[12];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
Serial.print(“Message: “);
Serial.println((char*)buf);
}
}

I certainly like the simple code, since the radio head library does all the heavy lifting for you. Have any of you ever tried these out?

Linux – keep it simple.