Week 11: Arduino LCD

Our Initial Task for this week was to find out about using Liquid Crystal Displays (LCD’s) with Arduinos and what that involves. I went to the Arduino help page for more information: https://www.arduino.cc/en/guide/libraries This site was very helpful in explaining the way that arduinos control LCD’s using libraries. It also covered some of the things that an LCD library would allow you to do:

Autoscroll: Shift text right and left.

Blink: Control of the block-style cursor.

Cursor: Control of the underscore-style cursor.

Display: Quickly blank the display without losing what’s on it.

Hello World: Displays “hello world!” and the seconds since reset.

Scroll: Scroll text left and right.

Serial Display: Accepts serial input, displays it.

Set Cursor: Set the cursor position.

Text Direction: Control which way text flows from the cursor.

Once I had had a look through this site, I decided to have a go so downloaded the LCD Library file and then moved it to the section in my documents labelled Arduino. Once I opened up the Arduino code editor, this was enough to install the Library. I checked this by using the dropdown menu sketch> Include Library> Manage Libraries.Arduino Library menu
After doing this, The next step was to download some code an hook up the display. I downloaded the test code from student central that displayed the message ‘ University of Brighton, Hello World!’ I also hooked up the screen to the board. I had to short the two pins on the LCD that control the backlight because they previously had a switch on them but that had been removed at some point. I did this with a crocodile clip as can be seen in the photo. It is worth noting that the screen still works without the back light, It’s just harder to see. I also had to connect the screen with 4 wires: one set of wires connected the screen with the 5v and ground output on the board. another two wires connected the board in the SDA and SCL ports which presumably are for transferring the data across.
Setting up my LCD
Hello world screen
Once I had this working, I went into the code and had a play around with making the text say different things and have it in different positions. this was fairly straight forward (simply changing the word in the brackets of the code) so I moved onto something a little more challenging. I wanted to make a pac man animation. I started off with just a ‘C’ chasing a ‘.’ which was fairly easy. I had an issue where the C’s were just left behind and never faded though so I fixed that by adding a clear screen command after each section of code.LCD with issue
code with edit
At this point I was told that it was possible to make custom sprites using binary. this meant that the thing that moves about the screen could be any shape I wanted it to (depending on the number of pixels). I discovered a website called https://maxpromer.github.io/LCD-Character-Creator/ which allows you to select which boxes you want to show up on the LCD. You check the boxes on the grid that you want to be highlighted and then the website gives you the binary for your design.
character creation site
I was then able to copy and paste this binary into the byte section of this code. I downloaded this code from https://gist.github.com/anonymous/10081245#file-gistfile1-c . This code is designed to show a text message: ‘I am out of the office right now’ and have a little pacman character being chased by a ghost and eating the blobs across the screen. I had a play around changing the pacman byte to other designs from the above website and and also had a go changing the text and spacing of the blobs.

Print Friendly, PDF & Email