Homemade RSS reader

This is a homemade, battery powered device that connects via
ethernet to any rss feed, picks out title tags and
reads them across an LCD. In this case, the BBC News frontpage. 
I'm planning on fitting it in an enclosure so
it can sit on your desk and just display concise headlines at
the touch of a button.
I made this at music hackday 2009, with the help of Mitch 
Altman (tv-b-gone) and  Peter Night (tinker-it).. 
however I seemed to have missed out the music bit....
Below is the rss reader source code for the arduino. 
You may want to change the ip and gateway addresses and
what RSS feed you are picking up.

#include <LiquidCrystal.h>
#include <Ethernet.h>

LiquidCrystal lcd(8, 7, 6, 5, 4, 3, 2);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,17 };
byte gw[] = {192,168,1,1};
byte server[] = {212,58,226,143};
char worrd[32];
char target[7] = {‘<‘, ‘t’, ‘i’, ‘t’, ‘l’, ‘e’, ‘>’ };
char tolcd[80];
int counter = 0;
int lcdcount = 0;
int count = 0;
int foundcount = 0;
int linecount = 0;
boolean worded = true;
boolean taketext = false;
boolean tag = false;

int ledPin = 13;

Client client(server, 80);

void setup()
{
Ethernet.begin(mac, ip, gw);
Serial.begin(9600);
// pinMode(1, OUTPUT);
delay(1000);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print(“connecting…”);

Serial.println(“connecting…”);

if (client.connect()) {
// Print a message to the LCD.
lcd.clear();
Serial.println(“connected”);
delay(1000);
lcd.print(“connected.”);
delay(1000);
client.println(“GET /rss/newsonline_uk_edition/front_page/rss.xml”);
client.println();
} else {
Serial.println(“connection failed”);
lcd.print(“connection failed.”);
}
}

void loop()
{
// lcd.clear();

if (client.available()) {

//only works if xml is formatted with line breaks
/* while(linecount < 2){
char c = client.read();
if (c == 10){linecount++;}}*/

char c = client.read();

if(c == ‘<‘){
for(int i=0; i<7; i++){
// Serial.print(c);
if(c != target[i]){ worded=false; }
c = client.read();

if(i==6 && worded==true){

//STUFF TO DO AFTER TITLE TAG GOES HERE
for(int i=0; i<80; i++){
tolcd[i]=’ ‘;}

//Serial.print(c);

while(tag==false){

if(c=='<‘){tag=true;}

tolcd[lcdcount]=c;
lcdcount++;
//Serial.print(c);
c = client.read();
}

for(int i=0; i<16; i++){
tolcd[lcdcount-1]=(‘ ‘);
lcdcount++;
}

Serial.print(lcdcount);

for(int p=0; p<(lcdcount-16); p++){

char dispchar = tolcd[p];
Serial.print(dispchar);

for(int i=0; i<16; i++){
lcd.setCursor(0, 0);
lcd.print(“Headlines:”);
char displaychar = tolcd[(i+counter)%lcdcount];
lcd.setCursor(i,1);
lcd.print(displaychar);

}

if(p==0){delay(1000);}
counter++;
delay(120);

}
counter=0;

lcdcount=0;

if(tag==true){tag=false; Serial.println(” “);}

}

}
}

if(worded==false){worded=true;}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s