Hi,
I am trying to connect my Arduino uno through firmata into processing. I have uploaded the standardFirmata code to my Arduino uno, added the Arduino/firmata lib to processing. Using this code I have established a working connection between Processing and Arduino IDE. The LED is flashing as it should be but somehow, the digitalRead does not read 1 when the LED is on. The console is continuously printing 0. What should I do? Thanks for help, I am very new to all of this
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int led = 2;
void setup() {
size(500,500);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[2], 57600);
arduino.pinMode(led, Arduino.OUTPUT);
}
void draw(){
arduino.digitalWrite(led, Arduino.HIGH);
int val = arduino.digitalRead(led);
println(val);
delay(1000);
arduino.digitalWrite(led, Arduino.LOW);
rect(250, 250, 100, 100);
val = arduino.digitalRead(led);
println("OO");
delay(1000);
}