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
int time;
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);
time = 0;
}
void draw() {
int s1State = arduino.digitalRead(s1);
if (s1State==Arduino.HIGH) {
ellipse(width/2,height/2, 230, 230);
}
}
switch (time) {
case 4:
// Do something
ellipse(720, 320, 30, 30);
break;
case 6:
// Do something
break;
}
Increment time
if (frameCount % 60 == 0) {
time++;
}
}
``
Answers
Delete both line 35 and 36. You close draw() too early.
@Averagejoe
Thank you so much. Now it works, but why the circle does not appear at the time?
@AverageJoe Hi! Dealt with this problem, the reason is that I made wrong orders in coding.
Thank you so much!