The AND Gate With Arduino

by PanosA6 in Circuits > Arduino

19424 Views, 13 Favorites, 0 Comments

The AND Gate With Arduino

AND_GATE_bb.jpg
gate_and copy.jpg

/**********************************
TITLE:  The AND Gate with Arduino
Created by: P.Agiakatsikas
the truth table
|A|B|Y| |0|0|0| |1|0|0| |0|1|0| |1|1|1| ************************************/ int buttonPin1 = 2; int buttonPin2 = 3; int LEDred = 8; int buttonStatus1 = 0; int buttonStatus2 = 0;
void setup() {
pinMode(LEDred, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
}
void loop(){
buttonStatus1 = digitalRead(buttonPin1);
buttonStatus2 = digitalRead(buttonPin2);
if (buttonStatus1 == HIGH && buttonStatus2 == HIGH ) { 
digitalWrite(LEDred, HIGH);
}
else { digitalWrite(LEDred, LOW);
}
}