import processing.serial.;
import cc.arduino.;
import eeml.*;
Arduino myArduino;
DataOut dOut;
DataIn dIn;
int ledNeg = 2;
int ledPos = 3;
int ledGreen = 9;
float myValue;
int myValueIn;
float lastUpdate;
void setup()
{
println(Arduino.list());
myArduino = new Arduino(this,Arduino.list()[0],57600);
dOut = new DataOut(this, "http://www.pachube.com/api/feeds/2698.xml","a4c94a8cd88cbdf1ece52fc750a9d39548e85bb1f8594d463f35ec4a45406425");
dOut.addData(0,"light level");
dIn = new DataIn(this, "http://www.pachube.com/api/feeds/2698.xml",
"a4c94a8cd88cbdf1ece52fc750a9d39548e85bb1f8594d463f35ec4a45406425", 5000);
}
void draw()
{
myArduino.analogWrite(10,myValueIn);
myArduino.pinMode(ledNeg,Arduino.OUTPUT);
myArduino.pinMode(ledPos,Arduino.OUTPUT);
myArduino.digitalWrite(ledNeg,Arduino.HIGH);
myArduino.digitalWrite(ledPos,Arduino.LOW);
myArduino.pinMode(ledNeg,Arduino.INPUT);
myArduino.digitalWrite(ledNeg,Arduino.LOW);
delay(30);
int j = 0;
int jFactor = 20;
int threshold = 0;
myValue = myArduino.analogRead(ledNeg);
for(j = 0;j<30000;j++){
if(j<=threshold) {
myArduino.analogWrite(ledGreen,0);
}
else{
myArduino.analogWrite(ledGreen,j*jFactor);
}
delay(30);
if(myArduino.digitalRead(ledNeg)==0) {
break;
}
}
print("j counter:");
print("");
print(j);
print("\t");
print("light value:");
print("");
print(myValue);
println();
myArduino.digitalWrite(ledPos,Arduino.HIGH);
myArduino.digitalWrite(ledNeg,Arduino.LOW);
myArduino.pinMode(ledPos,Arduino.OUTPUT);
myArduino.pinMode(ledNeg,Arduino.OUTPUT);
delay(500);
if((millis() - lastUpdate) > 10000) {
println("ready to PUT:");
dOut.update(0,myValue);
int response = dOut.updatePachube();
println(response);
println(myValue);
lastUpdate=millis();
}
}
void onReceiveEEML(DataIn d){
float remoteValue = d.getValue(0);
if(remoteValue <=199) {
myValueIn = 55;
}
else { //if light value is higher than 199,make red led inside bright
myValueIn = 255;
}
}
we are running the above code with results:
j counter: 0 light value: 0
2 out of 3 of our lights are lighting up....
we tried fumbling around with some numbers to see if the LEDs could respond to light intensity and give us variations of values in our results......
can anyone help:
where in the code is it controlling how the light behaves?
aka
why is my LED not acting as a sensor feed?
THANKS!