Problem with button code

here's the code

/*

*/
int relay = 5;
int butt1 = 7;
int butt2 = 10;

void setup() {
pinMode(relay, OUTPUT);
pinMode(butt1, INPUT_PULLUP);
pinMode(butt2, INPUT_PULLUP);

}

void loop() {
if (digitalRead(butt1) and digitalRead(butt2) == LOW) {
digitalWrite(relay, HIGH);
delay(100);
}
else{
digitalWrite(relay, LOW);
delay(100);
}

}

the problem is that i want it to only turn on if all of the buttons are pressed but it turns on if even a single button is pressed

if (digitalRead(butt1) == LOW and digitalRead(butt2) == LOW) 


Please use code tags in the future.

1 Like

Ok I will! Thanks!!!

OR

if ((digitalRead(butt1) and digitalRead(butt2)) == LOW) {

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.