Arduino Mega 2560
Also Using Adafruit motor shield
I am trying to make it so something happens when digitalRead(2) and digitalRead(3) both = 0.
I have:
{
do{
motor.run(RELEASE);
Serial.println(0);
}while ((digitalRead(2) == 0) && (digitalRead(3) == 0));
}
what am I doing wrong?
When it gets to that block of code, it will run the code in the do {} block once. Then, it will check the conditional, and run it again; repeat until the condition is no longer true.
What do you want it to do? Clearly not that - but it's not clear why if you want to do that when both conditions are true, you can't just use an if statement.
I'd suggest an if:
if ( (digitalRead(2) == 0) && (digitalRead(3) == 0) ){
// do something
}
else {
// do something else
}