Hi all-
I recently decided to purchase an Ethernet Shield for my Arduino Uno R3. I'm still pretty new to this kind of thing, but I figured I'd try to make my a code that would allow me to display (on an LCD I took from an AlphaSmart 2000, part#M028C) whatever I posted on Twitter. The only code I could find was the Twitter2LCD. There were two big problems still, though. Some of the libraries were out of date, and Twitter no longer supported RSS feeds. I found a good tutorial on making an RSS feed for Twitter (http://www.labnol.org/internet/twitter-rss-feeds/27931/), so I made my own RSS feed. After I finished editing the code for my particular LCD, I got it to upload to my Arduino. But once plugged into the router, I got the message "Could not find item field". How would I go about resolving this? The code includes the link to the Twitter account's RSS feed. Anything helps, thanks!
/*
* Twitter2LCD
// * gets xml data from https://script.google.com/macros/s/AKfycbz-MMUp0RmlMPAHn5jTA1ks--D-TduXHagIORr9f7IKzMlSvpA/exec?action=timeline&q=AaronDuino
* reads the most recent tweet from field: <title>
* writes the output to the LCD.
The circuit:
* LCD RS pin to digital pin A0
* LCD Enable pin to digital pin 5
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <Ethernet.h>
#include <SPI.h>
#include <TextFinder.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A0, 6, 5, 4, 3, 2);
LiquidCrystal lcd2(A0, 7, 5, 4, 3, 2);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte server[] = {67,215,65,132}; //Google Scripts
char tweet[140];
EthernetClient client;
TextFinder finder( client );
void setup()
{
lcd.begin(40,2);
lcd2.begin(40,2);
lcd2.print("AlphaDuino (-)(+)");
lcd.clear();
lcd.print("Twitter2LCD");
Serial.begin(9600);
Ethernet.begin(mac);
}
void loop()
{
lcd.clear();
if (client.connect(server, 80)) {
client.println("GET https://script.google.com/macros/s/AKfycbz-MMUp0RmlMPAHn5jTA1ks--D-TduXHagIORr9f7IKzMlSvpA/exec?action=timeline&q=AaronDuino");
}
else {
lcd.println("Connection failed");
Serial.println("Connection failed");
}
if (client.connected()) {
// get the last tweet by simply parsing the item and title tags
if((finder.find("<item>")&&(finder.getString("<title>","</title>",tweet,140)!=0)))
{
Serial.println(tweet);
for (int j=0; j<2; j++) {
// first part of the tweet
lcd.clear();
lcd.setCursor(0,0);
for (int i=0; i<20; i++)
lcd.print(tweet[i]);
lcd.setCursor(0,1);
for (int i=20; i<40; i++)
lcd.print(tweet[i]);
lcd2.setCursor(0,0);
for (int i=40; i<60; i++)
lcd2.print(tweet[i]);
lcd2.setCursor(0,1);
for (int i=60; i<80; i++)
lcd2.print(tweet[i]);
delay(10000);
// second part of the tweet
lcd.clear();
lcd.setCursor(0,0);
for (int i=60; i<80; i++)
lcd.print(tweet[i]);
lcd.setCursor(0,1);
for (int i=80; i<100; i++)
lcd.print(tweet[i]);
lcd2.setCursor(0,2);
for (int i=100; i<120; i++)
lcd2.print(tweet[i]);
lcd2.setCursor(0,3);
for (int i=120; i<140; i++)
lcd2.print(tweet[i]);
delay(10000);
}
}
else
lcd.println("Could not find item field");
}
else {
lcd.println("Disconnected");
}
client.stop();
client.flush();
delay(60000); // wait a minute before next update
}
-Aaron
Twitter2LCD.ino (2.88 KB)