Hello sorry for my english ,i'm french
I wish to obtain the flow rss to light(to switch on) a led on arduino .if the flow rss taken by processing changes a led starts. I have a processing code to take the rss but I do not know how to code arduino
please help me
Code:import processing.serial.*;
XMLElement xml;
XMLElement city;
XMLElement temperature;
XMLElement cond;
int interval = 10;
int lastTime;
String feed = "http://www.google.com/ig/api?weather=seoul&;hl=en";
String location;
String temp;
String condition;
// google api condition value list
String []condition_list = {
"Clear", "Cloudy", "Fog", "Haze", "Light Rain", "Mostly Cloudy", "Overcast", "Partly Cloudy", "Rain",
"Rain Showers", "showers", "Thunderstorm", "chance of Showers", "Chance of Snow", "Chance of Storm",
"Mostly Sunny", "Partly Sunny", "Scattered Showers", "Sunny"
};
int condition_index;
PFont font_title, font_normal, font_desc;
Serial port; // serial that communication with arduino
// setup section
void setup() {
size(800, 400);
frameRate(10);
font_title = loadFont("18thCentury-40.vlw");
font_normal = loadFont("18thCentury-20.vlw");
font_desc = loadFont("18thCentury-14.vlw");
fill(255);
textFont(font_title, 20);
String arduinoPort = Serial.list()[0];
port = new Serial(this, arduinoPort, 9600); // connect to Arduino
lastTime = 0;
fetchData();
}
void draw(){
background(0);
int n = (interval - ((millis() - lastTime)/1000));
textFont(font_title, 40);
text("Live WeatherCast", 10, 40);
textFont(font_normal, 20);
text("Reading feed:", 10, 70);
textFont(font_desc, 14);
text(feed, 10, 85);
textFont(font_normal, 20);
text(location, 10, 120);
textFont(font_desc, 14);
text("temperature : " + temp + "c", 10, 140);
text("condition : " + condition, 10, 160);
text("Next update in " + n + " seconds.", 10, 200);
if(n<=0){
fetchData();
lastTime = millis();
}
}
void fetchData(){
String chunk;
xml = new XMLElement(this, feed);
city = xml.getChild("weather/forecast_information/city");
location = city.getStringAttribute("data");
println("location: " + location);
temperature = xml.getChild("weather/current_conditions/temp_c");
temp = temperature.getStringAttribute("data");
println("temperature: " + temp);
cond = xml.getChild("weather/current_conditions/condition");
condition = cond.getStringAttribute("data");
println("condition: " + condition);
// println("list.length: "+ condition_list.length + "\n");
// search and get index of condition_list that match with data from google api XML data
for(int i=0; i<
condition_list.length ; i++){
if(condition_list[i].equals(condition)){
condition_index = i;
// println("xml_condition: " + condition);
println("");
println("found match in list index_"+i+" : " + condition_list[i] + " !!");
port.write(condition_index);
println("send index: ["+ i + "] to arduino!");
}
}
}