This project was mainly done as an excuse to learn how to use character LCD displays with my Arduino, and figure out how to make a bidirectional serial protocol. One major design goal was that the hardware would take user input and communicate back to the PC, not just run as a "dumb" display being driven entirely by the computer. This allows the Arduino to have a physical scrolling speed control which affects the script running on the PC.
- 16 x 2 character LCD displaying scrolling tweets from a chosen feed or search term
- Servo-operated flag raises when there are unread tweets (with no Arduino servo twitch!)
- Speed control dial adjusts scroll speed
- It's got Electrolytes
Step 1: System architecture
The hardware forms the Arduino's interface with the real world. The hardware consists of a two-line character LCD for displaying messages, a speed control that lets uers change the scrolling speed while the device is running, and a servo-operated flag that raises when the script detects there are unread tweets.
The sketch running on the Arduino runs a loop doing two main actions. It sends a "status" request to the script running on the server PC and awaits a response containing the number of tweets in the list, and whether there are any unread. It then sends a "message" request, gets the text of a tweet, and displays it scrolling across the display. It reads the potentiometer in real time to get the desired scroll speed, and raises and lowers the flag to notify of new tweets.
The server software maintains a list of all tweets seen since it started running. When the script receives a "status" request it replies with the number of tweets it currently has in the list, and whether there are any unread tweets. When it receives a "message" request the script sends the next tweet in the list, returning to the beginning of the list either when it reaches the end of the list or when it finds new tweets.
The script also has to keep the list of tweets up to date by checking the Twitter API to get the latest messages. This is also timed to occur at most once every three minutes: when the script receives a "status" request, if more than three minutes have elapsed since the last check, it gets the list of tweets and checks to see whether there are any unread.