Hi, I need help connecting my Processing sketch to my Arduino sketch. How do I sent the date, temp , weather, and woeid variable from Processing to Arduino. Thanks
Arduino Code:
//LCD Setup
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
//Serial Setup
Serial.begin(9600);
Serial myPort;
//Port setup
myPort = new Serial (this, "COM3", 9600);
//LCD Setup
lcd.begin(16, 2);
}
void loop() {
int inByte = Serial.read();
lcd.println(inByte);
}
Processing Code:
// Serial Comm with the Arduino
import processing.serial.*;
Serial myPort;
//variable used to store the temperature
int temperature = 0;
//Using 'date' as variable to store data
String date = "";
// store weather data
String weather = "";
String woeid = "24124932";
PFont font;
void setup() {
size(600, 360);
font = createFont("Georgia", 28);
textFont(font);
String url = "
http://weather.yahooapis.com/forecastrss?w=" + woeid;
// Loads the XML
XML xml = loadXML(url);
// Gets the XML element
XML forecast = xml.getChild("channel/item/yweather:forecast");
XML title = xml.getChild("channel/item/yweather:condition");
// Get the attributes we want
temperature = forecast.getInt("high");
weather = forecast.getString("text");
date = title.getString("date");
}
void draw() {
background(255);
fill(0);
// Display all the stuff we want to display
text("Last Updated: " + date, width*0.15, height*0.33);
text("Today’s high: " + temperature, width*0.15, height*0.5);
text("Forecast: " + weather, width*0.15, height*0.67);
text("WOEID: " + woeid, width*0.15, height*0.84);
myPort.write(date);
}