Compair two Strings (simpleML)
in
Contributed Library Questions
•
1 year ago
Hi!
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)
- port = new Serial(this, Serial.list()[0], 9600);
- // Creating and starting the request
- xmlRequest = new XMLRequest(this, "http://www.polisen.se/sv/Aktuellt/RSS/Lokal-RSS---Handelser/Lokala-RSS-listor1/Handelser-RSS---Skane/?feed=rss");
- xmlRequest.makeRequest();
- }
- void draw() {
- background(0);
- //Every 12 hours, make a new request
- int now = minute();
- if (now - startTime > 1) {
- 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[] kills = ml.getElementArray("title");
- //Filter "mord" tweets
- for (String kill : kills) {
- if (kill.toLowerCase().contains("mord")) {
- println(kill);
- // send a 'M(ord)' to indicate mouse is over square:
- port.write('M');
- }
- else {
- // send an 'L(ove)' to turn the LED off:
- port.write('L');
- }
- }
- }
1