Right now I have a code that reads an RSS feed, that filters the feeds titles, and then filters the titles for the word "mord", which then speaks to my Arduino board.
My problem is that I do not want it to trigger if the exact same string has been trigged before. So I basicly want to filter it.
For example, this line should only trigger my
port.write one time -
"
<title>2012-01-31 18:49, Mord/dråp, Malmö</title>". But currently it triggers everytime it refreshes the RSS feed.
Any hints?
import simpleML.*;
import processing.serial.*;
XMLRequest xmlRequest;
int startTime;
Serial port;
void setup() {
// List all the available serial ports in the output pane.
// You will need to choose the port that the Arduino board is
// connected to from this list. The first port in the list is
// port #0 and the third port in the list is port #2.
println(Serial.list());
// Open the port that the Arduino board is connected to (in this case #0)
// Make sure to open the port at the same speed Arduino is using (9600bps)
I am trying to filter my array ( which is a RSS feed, which is getting updated every five seconds) for a keyword "bieber".
I've managed to get the rss feed going, which you will see if you run the program. But I don't know how to filter out the word "bieber" (which occurs occasionally).
Also, when the word "bieber" occurs I want it to be saved in a "int bieberHate =++", that counts everytime the word is being spoken of.
Im glad for any hints!
import simpleML.*;
XMLRequest xmlRequest;
int startTime; // for the timer to make request ever N seconds
int bieberHate; // declare a varible for each time Bieber is spoken of.
void setup() {
size(200, 200);
// Creating and starting the request
xmlRequest = new XMLRequest(this, "http://www.search.twitter.com/search.rss?q=love");
xmlRequest.makeRequest();
}
void draw() {
background(0);
// Every 5 seconds, make a new request
int now = millis();
if (now - startTime > 5000) {
xmlRequest.makeRequest();
println("Making request!");
startTime = now;
}
}
// When the request is complete
void netEvent(XMLRequest ml) {
// Retrieving an array of all XML elements inside "<title*>" tags
String[] tweets = ml.getElementArray("title");
for (int i = 0; i < tweets.length; i++) {
println(tweets[i]);
}
//filter my array, only displaying if the string contains the word "bieber", and if it does, it should increase the value of my int bieberHate by 1.