Step 4: The Arduino Code

// This code is for the Arduino RSS feed project, by Fritter
// Read the comment lines to figure out how it works

int startstring = 0;     // recognition of beginning of new string
int charcount = 0;     // keeps track of total chars on screen
#include  <LiquidCrystal.h>  // import the LiquidCrystal Library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
         Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
         lcd.begin(16,2);            // Initialize the LCD size 16x2. Change if using a larger LCD
         lcd.setCursor(0,0);     // Set cursor position to top left corner
         pinMode(13, OUTPUT);

void loop() {
        char incomingByte = 0;   // for incoming serial data
         if (Serial.available() > 0) {        // Check for incoming Serial Data
                 digitalWrite(13, HIGH);
                 incomingByte = Serial.read();
                 if ((incomingByte == '~') && (startstring == 1)){            // Check for the closing '~' to end the printing of serial data      
                   startstring = 0;                                                                  // Set the printing to off
                   delay(5000);                                                                     // Wait 5 seconds
                   lcd.clear();                                                                         // Wipe the screen
                   charcount = 0;                                                                   // reset the character count to 0
                   lcd.setCursor(0,0);                                                          // reset the cursor to 0,0
                 if (startstring == 1){                                                             // check if the string has begun if first '~' has been read
                   if (charcount <= 30){                                                        // check if charcount is under or equal to 30
                     lcd.print(incomingByte);                                                // Print the current byte in the serial
                     charcount = charcount++;                                             // Increment the charcount by 1 yes I know it's awkward
                   if (charcount == 31){                                                         // if the charcount is equal to 31 aka the screen is full
                     lcd.clear();                                                                        // clear the screen
                     lcd.setCursor(0,0);                                                         // set cursor to 0,0
                     lcd.print(incomingByte);                                                // continue printing data
                     charcount = 1;                                                                 // set charcount back to 1
                 if (incomingByte == '~'){                                                    // Check if byte is marker ~ to start the printing
                   startstring = 1;                                                                  // start printing
                 digitalWrite(13, LOW);
                 delay(10);                                                                            // 10ms delay for stability
<p>How would I make this display weather forecast?</p>
Is the entire board really necessary, i.e. can't I get the results with a standalone arduino circuit?<br>
<p>I got this error when I ran the code in phyton , please help me out!</p>
<p>Can this be done with a LED matrix?</p>
I made this!! It's so cool here's the photo.
<p>How can you use arduino code for a 20x4 LCD?</p><p>I tried changing the size in the code, but it does not work. When it comes to the second line it clears the lcd and the other part is displayed. Please help.</p>
Is there way to use multiple lines? i use this feed: http://feeds.feedburner.com/p2000-regio-noord-holland-noord which is a feed of the 911 calls nearby my village. i tried changing the charcount, but im not very good with arduino. PLEASE HELP ME
I'm getting this error. What does this mean. Apologies I have never used python before. <br> <br>line 39, in <br> ser.write(num) <br> File &quot;C:\Python27\lib\site-packages\serial\serialwin32.py&quot;, line 283, in write <br> data = to_bytes(data) <br> File &quot;C:\Python27\lib\site-packages\serial\serialutil.py&quot;, line 76, in to_bytes <br> b.append(item) # this one handles int and str for our emulation and ints for Python 3.x <br>TypeError: an integer or string of size 1 is required <br> <br>
I found a solution. I put this line num=str(num) just before ser.write(num) so python recognises num as a string
i also think that the settings for the ports have also been changed
i think you need to rewrite the python code because an update meshed urllib2 into urllib, i'm trying to debug it, but this is my first time seeing python, luckily programming is my thing
great work!! But there is one problem I have came across after implementing this. What is news contents contains &quot; 's &quot; as part like in &quot; that's &quot; then this Python script is unable to parse it and send it to arduino via serial so any help on this ??
Very cool. Thank you for posting. I have gotten it work but it doesn't use the second line of text, therefore words are not showing up. I think there is an error in the Arduino code because if I use Arduino's example serial display it works but it only prints one word then reprints the whole screen. Help? Please
What size is your LCD display?
Could it be a problem with the LiquidCrystal Library? I don't exactly understand that part of it. Am I supposed to put the .h file in a certain place?
16x2. Hello World works with the second timer at the bottom.
Very nice project. <br>I was wondering, if I do have the PC working on chewing up the web data, why do I need Arduino at all? I mean, I can have a much cheaper USB-to-Serial connecting the USB port of the PC to an LCD. As a matter of fact, CrystalFontz sell USB connected LCD screens, so the PC could simply manage the display too.
I did something like this awhile ago using a beta-bright moving message sign, PHP script, and a home made serial cable, works quite well, I use it right now to display weather information and forecasts, but it can be used to do just about anything else that you would like displayed. In fact it works so well that I got myself a 2nd larger sign for the living room (Wife doesn't really like that one thou LOL) http://youtu.be/VoiIjmh4Qrg - Thought you might be interested thou because it just uses the computer and the beta-bright display protocol.
Thanks kd8bxp (And I must admit is sounds like Radio Amateur code),<br>I did play with CrystalFontz a while back. Recently built few things where the micro-controller is basically standalone, connect to the Internet and display stuff on visual screen. See my Instructables. If the display is a small VGA one it has a higher wife-acceptance factor :-) The &quot;old&quot; 15&quot; LCD display has now good use in the living room
In this case the Arduino just manages the LCD and pieces together incoming words into proper, readable format. If you had a plain LCD with a USB connector and the proper software to interface with it via USB, then you could just use the screen. <br> <br>I used the Arduino because I had it on hand and this was never meant to be a permanent build. I built it for fun, got it to work then took it apart and went onto the next Arduino project.
I know about fun, and totally agree with that.
I could be wrong, but charcount=charcount++; won't do anything. <br> <br>If you want to increment, you only need this: <br> <br>charcount++; <br> <br>That will increment by one.
It will in fact add 1 to the total, but it is redundant. <br> <br>the ++ modifier essentially acts as variable = variable + 1 <br> <br>So in this case it says variable = variable = variable + 1 <br> <br>It works, but should simply say charcount++ for the sake of simplicity and easier reading. Thanks for pointing it out.
Technically, the behavior is &quot;undefined&quot; which means it might do what you want, or it might not. The actual behavior is up to your C compiler, and *any* behavior is permitted, including not compiling the code, or producing code with <em>wildly</em> unexpected behavior.<br> <br> In case you care: the reason it's undefined is that the C language spec says modifying the same variable multiple times within the same expression without an intervening &quot;sequence point&quot; is undefined. There are no sequence points in that expression, and charcount is being modified twice. This exact topic used to be a common question on the C programming groups on USENET. About once a week someone would ask why one compiler would behave differently than another when compiling &quot;i = i++&quot; (often the question was &quot;which one is right?&quot;).<br> <br> Here's a Stack Overflow question on this topic:&nbsp;<a href="http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc" rel="nofollow">http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc</a>
Thanks for the definitive answer. So while I can confirm it would work properly for me, it might not work properly if you use a different compiler. Really is playing a game of chance with your code, I guess.
If you get a could not open port error try finding the correct port this way: <br> <br>In terminal type: python -m serial.tools.list_ports <br>Find the port matching the one in the Arduino settings and copy paste into your python script.
this is really simple <br>and impressive <br>but the python language , this is the first time i see somebody using it in arduino <br>really really goooood <br> <br>big thank you bro <br>even your project is simple but a new stuff has been learned today <br>
This is very cool. I like this a lot.
This is Pretty cool, and from the looks of the code it might be just simple, yet interesting enough to get me into python <br> Nice article thanks. <br> <br>1. question though in the beginning of the arduino code. <br>Is the below lines a typo? shouldn't it include something? <br>or is it usingLiquidCrystal lcd(12, 11, 5, 4, 3, 2); as the include I no you said we need to download a new library but i never seen an include with pin assistants included, maybe it does not matter I'm just curious. <br> <br>#include // import the LiquidCrystal Library <br>LiquidCrystal lcd(12, 11, 5, 4, 3, 2); <br> <br>

About This Instructable


124 favorites


Bio: Bugtesting from here to infinity and beyond.
More by fritterdonut: An Arduino RSS Feed Display
Add instructable to: