Hello! I am trying to make different things happen when I have more than one switch pressed (break from the current loop). Trouble is, it's not working at all. It completely neglects the double code.
I have it wired so the the r is the reading from the switches. I have it set up so the switches are HIGH inputs. Whenever I try to hit both of the switches, it flashes one light then flashes the next (the digitalWrites are for LED pins).
It works every once in a while, so I'm guessing the code might be correct but my approach is wrong. What I want to happen is the user presses a switch, and if both switches are pressed, something happens. If a switch is pressed and released, the single action happens. Are these HIGH/LOW values correct?
Also, my r(1)o values are the old ones, changed at the end of my loop. All of this is enclosed in a while loop, but it's long so I'll just post a segment.
Thanks!
if(r1 == HIGH && r2 == HIGH && r1o != r1 && r2o != r2)
{
digitalWrite(m1, HIGH);
digitalWrite(m2, HIGH);
delay(t);
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
}
if (r1 == HIGH && r1 != r1o)
{
digitalWrite(m1, HIGH);
delay(t);
digitalWrite(m1, LOW);
}
if (r2 == HIGH && r2 != r2o)
{
digitalWrite(m2, HIGH);
delay(t);
digitalWrite(m2, LOW);
}