boolean Status1 = digitalRead(3);
boolean Status2 = digitalRead(4);
if ((Status1==HIGH) && (Status2==HIGH))
{
digitalWrite(0,HIGH); //Your Logic Result on Pin 5
//add a delay for example
//delay(400);
}
else
digitalWrite(0,LOW);
- define the input / output pins somewhere so your program is more portabe;
- you can easily rewrite that to this:
#define AND(x, y) (digitalRead(x) && digitalRead(y))
...
digitalWrite(OUTPUT_PIN, AND(INPUT_PIN1, INPUT_PIN2)); //output and of pin1/pin2 on output pin
You can implement other functions similarly.
- things like this have very limited uses: the test is done only when that line was executed. So a transistion when that line isn't executed will be missed - I would use an interrupt for sure.