Create Custom Animations on 16x2 LCD Displays
by tusindfryd in Circuits > Arduino
2300 Views, 2 Favorites, 0 Comments
Create Custom Animations on 16x2 LCD Displays
The LiquidCrystal library makes it easy to use LCDs with Arduino. A particularly interesting function from that library is the createChar() function: you can create custom glyphs (characters), each described by an array of eight bytes, one for each row. The five least significant bits of each byte determine the pixels in that row. Writing bytes by hand to create art is not exactly an artist's ideal process, so I have made a web tool in which you can draw the glyphs, and the code is generated for you.
In this article I will show how to create custom animations having only just any Arduino board and an LCD - which you can use to create a whole lot of projects: you can make a game, or a short story, or a music video, or decorate a status panel.
Supplies
- any Arduino board
-
any LCD display in size 16x2 that is compatible with the Hitachi HD44780
Connecting the LCD to the Arduino
Connect the LCD to the Arduino as shown in the schematic.
Creating Art
Go to the tool at https://tusindfryd.github.io/screenduino/ and create your art. Up to 8 sections can be used at once, so if you cannot select a new square, make sure you're not using 8 sections already.
Generating the Code
When you're done with your first image, uncheck the box "just the function". Copy the code to clipboard and upload it onto your Arduino. At this point you should see your image on the LCD - pretty neat, right?
Making More Frames
Make sure your code is saved. You can now create the second frame. Just draw another image. When you're done, check the box "just the function". Copy the function and paste it at the end of your code. Rename the new function to something else - like image01(), so that you can keep track. Now you will need to move the call to image() from the setup() function to the loop() function, add a delay, call image01(), and add a delay again. Consider renaming image() to image00() for consistence. Your loop() function should look something like this:
void loop()
{
image00();
delay(250);
image01();
delay(250);
}
Upload the sketch onto your Arduino. Try adding more frames or changing the delay time.