We are about to switch to a new forum software. Until then we have removed the registration on this forum.
`import org.firmata.*;
import cc.arduino.*;
import processing.serial.*;
Arduino arduino;
int s1 = 7;//(r) //sensor1
int s2 = 8;//(y) //sensor2
int s3 = 9;//(b) //sensor3
int s4 = 10;//(g)//sensor4
int s5 = 11;//(b)//sensor5
void setup() {
size(500, 500);
background(255);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[4], 57600);
arduino.pinMode(s1, Arduino.INPUT);
arduino.pinMode(s2, Arduino.INPUT);
arduino.pinMode(s3, Arduino.INPUT);
arduino.pinMode(s4, Arduino.INPUT);
arduino.pinMode(s5, Arduino.INPUT);
}
void draw() {
if (arduino.digitalWrite(s1, Arduino.LOW)) {
ellipse(50, 50, 50, 50);
}
}
`
When the sensor gets information, a circle will appear. But now it cannot work! WHY?
Answers
Please format your code using the C button (ctrl+o). Nobody is going to read your code like that.
Your error appears for example when you use a method that doesn't return anything in a place where the compiler expects a boolean, like in the condition of an if statement.
arduino.digitalWrite(s1, Arduino.LOW)returns void because it writes, not reads.You want
arduino.digitalRead(s1, Arduino.LOW)It's right on the front page for the firmata library. Scroll down a bit for available commands
http://playground.arduino.cc/Interfacing/Processing
@AverageJoe Thank you so much for your help. I achieved it.
@colouredmirrorballcolouredmirrorball Thank you so much