Untitled
unknown
plain_text
a month ago
987 B
2
Indexable
Never
int button1 = 2; int button2 = 3; int led1 = 4; int led2 = 5; int led3 = 6; void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(button1, INPUT); pinMode(button2, INPUT); Serial.begin(9600); } void loop() { int buttonState1 = digitalRead(button1); int buttonState2 = digitalRead(button2); if (buttonState1 == HIGH) { digitalWrite(led1, HIGH); } else { digitalWrite(led1, LOW); } // GERBANG AND (DAN) if (buttonState1 == HIGH && buttonState2 == HIGH) { digitalWrite(led2, HIGH); } else { digitalWrite(led2, LOW); } // GERBANG OR (ATAU) if (buttonState1 == HIGH || buttonState2 == HIGH) { digitalWrite(led3, HIGH); } else { digitalWrite(led3, LOW); } // MEMONITOR KONDISI BUTTON Serial.print("button1: "); Serial.println(buttonState1); delay(1000); Serial.print("button2: "); Serial.println(buttonState2); delay(1000); }
Leave a Comment