Go Down

Topic: Send value from Processing to Arduino (Read 772 times) previous topic - next topic

AlanArduino

Hey,

I'm using the following processing code to retrieve a value from a URL and print it.  





import eeml.*;
float  data;
DataIn dIn;
String xx;

void setup(){
   // set up DataIn object; indicate the URL you want, your Pachube API key, and how often you want it to update
   // e.g. every 5 seconds    
   dIn = new DataIn(this,"http://www.URLwithDATA.xml", "key", 5000);
}

void draw()
{
   // do whatever needs doing in the main loop
   print(data);
   println(xx);
   
}

// onReceiveEEML is run every time your app receives back EEML that it has requested from a Pachube feed.
void onReceiveEEML(DataIn d){
   float myVariable = d.getValue(1); // get the value of the stream 1
    xx = d.getStatus();
    data = myVariable;
   //println(myVariable);
}


Could anyone please give me some code to use in an Arduino sketch to read this value from processing??

billroy

If you put Bitlash (http://bitlash.net) on the Arduino, you can send  commands over the serial link from Processing for Bitlash to execute for you.  It will handle all the parsing and serial port stuff on the Arduino side.  

Exactly what Bitlash commands you'd send would depend on what you're trying to get the Arduino to do, of course.  One nice thing about an interpreted shell is that you can debug and get it working by hand in a serial terminal, and then automate with Processing or your favorite PC side language.

Happy hacking,

-br
http://bitlash.net
http://entropymouse.com

Go Up