Need help with getting data in from pachube to processing

Hi Guys can anyone please help me with my Pachube to Processing problem.

I have a data feed up on pachube which is working fine but I cannot get the data back into processing using a different arduino to output.

Basically what I what it to do is to have a threshold value and if the value is less then the predefined threshold it will simply turn on an LED.

I have been able to to do successfully just using one arduino on one computer but my programming skills are not good enough for converting to processing.

I’m pretty sure the problem is in my for loop statement.

Here is the sketch I am using to get the data from the xml feed.

Could someone please tell me in how i go about getting this working.Thanks in advance

// Arduino Setup for recieving Push Button Values
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
 Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
 Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW };
 
//Pachube Setup
import eeml.*;
float  data;
DataIn dIn;
String xx;

// variable to store the value 
  int value = 0;
  
// a threshold to decide when the LED turns on
  int threshold = 343; // when the reading drops below this value the LED will turn on
 

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 7 seconds    
    dIn = new DataIn(this,"http://api.pachube.com/v2/feeds/19423.xml", "_aL1KdQHxFr-9gpStCoR5es_0k_e_aoryYk5bOS3EzQ", 7000); // API of tangeeble account // Request every 7000
    //Init Arduino
    println(Arduino.list());
    arduino = new Arduino(this, Arduino.list()[0], 9600);
   //Setting all Digital pins to output
   for (int i = 0; i <= 13; i++) {
      arduino.pinMode(i, Arduino.OUTPUT);
   }
}

void draw()
{
    // Receive data
    print(data);
    
    
    /// start of my own code
    
    value = dIn;
      
      values[13] = Arduino.pinMode (Arduino.OUTPUT);
    // if the value of the data coming into the is greater than the threshold, turn on led.
    
    if (value < threshold) {
      
    values[13] = Arduino.HIGH;  //on
    
    }
    
    else {
      
        values[13] = Arduino.LOW;   // off
    }

     
    delay(7000); // wait 7 seconds before sending it off to pachube
    
}

// 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(0); // get the value of the stream 1
     xx = d.getStatus();
     data = myVariable;
    println(myVariable);
}
values[13] = Arduino.pinMode (Arduino.OUTPUT);

The pinMode function does not return a value. No clue what you are storing in values[13].

    if (value < threshold) {
    values[13] = Arduino.HIGH;  //on
    }
    else { 
        values[13] = Arduino.LOW;   // off
    }

Simply storing some value in values[13] will not make the LED turn on. You actually have to call digitalWrite() at some point.

ok thank you, I will give that go. cheers

Ok so I have modify my code and think i'm almost there.. still not getting any reading back from pachube. Could some one please see if i'm missing anything.. thanks in advance,

import eeml.*;
import processing.serial.*;
import cc.arduino.*;        



float  data;
DataIn dIn;
Arduino arduino;


int ledPin10 =  10;
int ledPin11 =  11;
int ledPin13 = 13; 

int threshold;

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 7 seconds   


dIn = new DataIn(this,"http://api.pachube.com/v2/feeds/18952.xml","MY_API_KEY", 7000);  

print("List out the Serial Ports and numbers");  

println(Arduino.list()); arduino = new Arduino(this, Arduino.list()[0], 115200); 

arduino.pinMode(ledPin10, Arduino.OUTPUT);
arduino.pinMode(ledPin11, Arduino.OUTPUT);
arduino.pinMode(ledPin13, Arduino.OUTPUT);

size (200,200);  
}

void draw(){ 

  
if (threshold >  100 ) {      // if the LDR is less than 100 

arduino.digitalWrite(ledPin10, Arduino.LOW); 

arduino.analogWrite (ledPin11, Arduino.LOW);

arduino.analogWrite (ledPin13, Arduino.LOW);


{  

 arduino.digitalWrite(ledPin10, Arduino.HIGH); 

arduino.digitalWrite(ledPin11, Arduino.HIGH);

arduino.digitalWrite(ledPin13, Arduino.HIGH); 


     }

 }

}

// 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(3); // get the value of the stream 1   
data = myVariable;   
int threshold = (int) myVariable;
println(myVariable);  
println(threshold);   

}

I don't know why you are not getting anything from pachube, but, there are problems with your Processing application.

int threshold;

This is a global variable that has not been assigned a value. This:

void draw(){ 

  
if (threshold >  100 ) {      // if the LDR is less than 100 

arduino.digitalWrite(ledPin10, Arduino.LOW); 

arduino.analogWrite (ledPin11, Arduino.LOW);

arduino.analogWrite (ledPin13, Arduino.LOW);


{  

 arduino.digitalWrite(ledPin10, Arduino.HIGH); 

arduino.digitalWrite(ledPin11, Arduino.HIGH);

arduino.digitalWrite(ledPin13, Arduino.HIGH); 


     }

 }
}

is a mess. Random amounts of white space, no consistent indenting, and it references the unassigned global variable.

This, on the other hand:

void onReceiveEEML(DataIn d){    
  
float myVariable = d.getValue(3); // get the value of the stream 1   
data = myVariable;   
int threshold = (int) myVariable;
println(myVariable);  
println(threshold);   

}

has the same random white space and poor indenting style, but it creates a local variable that it does value (well, it would if the function were actually called). That local variable goes out of scope when the function ends, and the value in that variable is lost.

Why is the value of stream 1 referenced using 3?