We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Reading an RSS feed character by character.
Page Index Toggle Pages: 1
Reading an RSS feed character by character. (Read 676 times)
Reading an RSS feed character by character.
May 1st, 2009, 2:54am
 
Hi,
I have managed to take an RSS feed fom twitter using twitter4j and display it on a Processing program, and what I am now trying to do is read the feed character by character so that I can send the data to an arduino. I am unsure where to start with this, can anyone give me any hints or tips?

Here is what I have so far........


void setup(){
size (500,125);
 
}
void draw(){

int startingPoint = 0;
Twitter twitter;
int myFriendsCount;
User[] friends;
String username = "username";
String password = "password";
twitter = new Twitter(username,password);
String myTimeline;
PFont font;
 // Setup font
 font = loadFont("CourierNew36.vlw");
 textFont(font, 24);
size (500,150);
background (0);
   
text("hello twit",20,60);

try
{
java.util.List statuses = twitter.getUserTimeline();
 //List statuses = twitter.getUserTimeline();

  Status status = (Status)statuses.get(0);
  println(status.getUser().getName() + ":" + status.getText());
  text(status.getText(), 20, 30);  
}
catch( TwitterException e)
{
// catch error here
}
delay(120000);
loop();
}




Cheers,
Mike
Re: Reading an RSS feed character by character.
Reply #1 - May 1st, 2009, 5:20am
 
well.. several ways to do it..
this is how you send data from processing to arduino;
http://dma.ucla.edu/senselab/node/353

and to read each character in a String (String text = status.getText()Wink
i think this should work;
for(int i = 0 ; i < text.length(); i++){
 char c = text.charAt(i);
 // send the char with the code in the link above
}
Re: Reading an RSS feed character by character.
Reply #2 - May 1st, 2009, 7:55am
 
Thanks Seltar,
I have no problems with getting data to the arduino, but thanks for your suggestions. Do I just need to put the code you suggested:

              {
               String text = status.getText() ;
               for(int i = 0 ; i < text.length(); i++);
               }{
               char c = text.charAt(i);
               }


Just after this bit of my code....



  Status status = (Status)statuses.get(0);
  println(status.getUser().getName() + ":" + status.getText());
  text(status.getText(), 20, 30);


Or is it instead of it?? Sorry if this sounds like a stupid question, I'm quite new to Processing/Arduino and this is by far the most technical thing I've done.

Cheers,

Mike
Re: Reading an RSS feed character by character.
Reply #3 - May 12th, 2009, 8:41am
 
Sorry for the late reply.
Code:

Status status = (Status)statuses.get(0);
String text = status.getText();
for(int i = 0 ; i < text.length(); i++){
char c = text.charAt(i);
// HERE you need to insert the code to send each char to the arduino
// something like this, if you named your variable of Serial 'port'
port.write(c); // write the character we're currently at
}

// display it (i guess, since you had it in your code already)
println(status.getUser().getName() + ":" + status.getText());
text(status.getText(), 20, 30);
Page Index Toggle Pages: 1