Connecting Two Push Buttons To Arduino.. Taking the Input From Them Using DigitalRead() via Arduino Digital Pins and Switching On the Led If The Both the Push Buttons are Pressed.
The Values of LED resistor : 220 ohms
PushButton resistors : 1 Mohm Each
Code :
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT);
pinMode(7,INPUT);
pinMode(11,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(11) && digitalRead(7))
digitalWrite(3,HIGH);
digitalWrite(3,LOW);
}
change the && into || and See the Ouput
Output:
No comments:
Post a Comment