first of all, i have to tell you that i'm really new into this arduino thing.. i know arduino provide everything to make things simple but i have to admit it still take me some time to adapt.. hope you guys, seniors can help me.. anyway, i have bought 2 sure electronic 32x16 led matrix display and i have use a coding i get from this arduino forum.. frankly said, it is not me who found the code, its my friend's.. he give me the code and ask me to upload the code to arduino Uno and poof! it works!! there is character displayed on the LED matrix.. since that coding works, then i have purchased an ethernet shield.. my intention is to get the tweet update from the twitter website.. so, i have googled about "how to receive twitter feed arduino" and got some coding that i think will work fine.. the problem now is i have both coding, for the LED matrix display and for twitter, but i don't know how to combine both coding or can i say how to merge the twitter coding into the LED matrix coding? btw, i have posted both coding in the next post below ( cannot post in same post, exceeds limit ).. hope somebody can help me with this.. thanks in advance..
led matrix coding - cannot post led matrix coding due to character limit, so i upload it to mediafire so that everybody can download
Twitter coding
/*
* TWITTERFEED SHOWN on SERIAL MONITOR
*
* last changed 23/02/2012
*
* Version 1.0
*
* Arduino 1.0 is needed !!!
*
* Made by JO3RI check check http://www.jo3ri.be/arduino
*
*/
#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xE4 };
byte ip[] = { 192,168,1,10}; //change this
byte subnet[] = {255,255,255,0}; //change this
byte gateway[] = {192,168,1,1}; //change this
byte dns[] = {192,168,1,1}; //change this
EthernetClient client;
String TwitterName ="JO3RI"; //change this to your own twittername, or follow me ;-)
char tweet[140];
String SearchString ="<title>";
byte charsize;
char serverName[] = "api.twitter.com"; // twitter URL
void setup() {
// initialize serial:
Serial.begin(9600);
// attempt a DHCP connection:
Ethernet.begin(mac, ip, dns, gateway, subnet);
// connect to Twitter:
delay(3000);
}
void loop(){
Serial.println("connecting to server...");
if (client.connect(serverName, 80)) {
TextFinder finder( client,2 );
Serial.println("making HTTP request...");
// make HTTP GET request to twitter:
client.print("GET /1/statuses/user_timeline.rss?screen_name=");
client.print(TwitterName);
client.println("&count=1 HTTP/1.1");
client.println("HOST: api.twitter.com");
client.println();
Serial.println("sended HTTP request...");
while (client.connected()) {
if (client.available()) {
Serial.println("looking for tweet...");
SearchString = SearchString + TwitterName + ": ";
charsize = SearchString.length() + 1;
char StartHere[charsize];
char EndHere[] = "</title>";
SearchString.toCharArray(StartHere,charsize);
if((finder.find("<item>")&&(finder.getString(StartHere,EndHere,tweet,140)!=0)))
Serial.println(tweet);
break;
}
}
delay(1);
client.stop();
}
Serial.println("delay...");
delay (60000);
// don't make this less than 30000 (30 secs), because you can't connect to the twitter servers faster (you'll be banned)
// off course it would be better to use the "Blink without delay", but I leave that to you.
}
I didn't take a look at the code you uploaded to mediafire but the logic should probably progress this way in your loop:
Do the internet and server connection
Get the tweet
Display the tweet using the htc1632c.
Steps 1 and 2 are covered in the code you posted. The tweet gets printed to the serial monitor with the following line: "Serial.println(tweet);" Instead (or in conjunction with) this you want to display it on the LED modules. I made a function that lets me interface with the LED modules pretty easily to display text:
/* Function Name: Displayer
Purpose: Handles all necessary display controls. It will decide whether or
not to scroll the text.
Author: doubledaffy
Last Updated: 03/13/12
*/
void Displayer(char *text, int y/*=0*/, boolean xcentered/*=false*/,
int x/*=0*/, int delaytime/*=25*/, int times/*=1*/, int color/*=1*/){
//Determine text width
int len = strlen(text);
int textlength=fontwidth*len;
if(xcentered==true){
x=round((max_x-textlength)/2);
}
if(textlength>max_x){
dotmatrix.hscrolltext(y, text, color, delaytime, times);
}else{
StaticText(x,y,text,color,fontwidth);
}
x=0;
y=0;
}
/* Function Name: StaticText
Purpose: Taken from user "mezelve" on the arduino forum this allows
single-line static text to be displayed at coordinates x and y
Author: mezelve from arduino.cc/forum
Last Updated: 03/13/12
*/
void StaticText(int x, int y, char *text, byte color, int w){
int len = strlen(text);
for (int i = 0; i < len; i++){
dotmatrix.putchar(x + (w * i), y, text[i], color);
}
dotmatrix.sendframe();
}
You'll have to setup the boards properly (mine is named "dotmatrix" in the example code above), but that is covered elsewhere on this forum. Make sure you don't use the same pins that the ethernet chip uses when outputting the display information, otherwise it won't work.