The goal of this project is simple:
- Read a message from the serial console, and display it upon the LCD.
- Because we allow long-inputs, we'll implement character scrolling.
- To allow arbitrarily long messages we assume user will add '
#' to terminate the input.
- Once read the message can be dismissed by pressing a button.
- Pressing the button will clear the display.
This project requires only minimal skill, if you've worked through the projects included in the official starter kit, this is because we're just taking the wiring from two of the sample projects, and combining them:
- Wire the LCD display to the arduino, as per project 11 in your starter-guide.
- Wire a button to a spare input-pin, as per project 2 in your starter-guide.
- In the sample code listed below this is pin 7.
The end result will look something like this:
The code is pretty simple, if you've already completed the starter-project you know how to display text upon the screen. We're just updating that example to read from the serial console, when data becomes available, and clear things when the button is pressed.
Once you've loaded the code in your IDE, compiled & uploaded it, your display should show:
This is the default message. by Steve
You can open the serial interface in your IDE and type in a new message:I like cakes, I also like puppies and kittens!#
NOTE: The "
#" character will signify the end of the message, and will not be displayed.
The new message will cheerfully scroll across the first line of the display, and will continue to do so until you press the button you've wired up. Think of the button as an "acknowledge & clear" thing.
ProTip: If your board is connected to a Linux system you can update the message from your shell.
In my case I can run this to update the message:
$ echo "I am awake#" > /dev/ttyACM2
- At the moment the first line always scrolls.
- Can you make it only scroll if the input is longer than the 16 characters that will fit on it?
- The second line just contains the string "by Steve".
- Can you split the message across two lines, with no scrolling, if the message is less than 32 characters?
If you're using a D1-mini, or some other board which has built in networking, can you make the message come from a remote HTTP server?