We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I'm trying to create a button that adds 5 to an int. Then, when it reaches a certain stage (255) I want to change it around so instead of adding 5 it subtracts 5. I have done this once before but for some reason I can't get it to work this time. Does anyone see my mistake?
if (color1 >= 255) {
button5 = true;
}
if (color1 <= 0){
button5 = false;
}
if (arduino.digitalRead(5) == Arduino.HIGH){ //a real life button connected to processing with the Arduino
if (button5 = false){
color1 = color1 + 10;
}
else{
color1 = color1 - 10;
}
println("button 5");
println(button5);
}
Answers
A single = is an assignment statement.
For comparisons, use the == operator.
However, you don't have to compare booleans like that. Booleans are already booleans.
Can just be:
We can also switch
true
&false
states this way: