Advertisement
lovelymondayss

timedoor intermediate pertemuan 3

Aug 18th, 2022
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | Writing | 0 0
  1. int buttonPin =2;
  2. int buttonState=0;
  3. int ledPin =  9;
  4. void setup() {
  5.   Serial.begin(9600);
  6.   pinMode(buttonPin, OUTPUT);
  7.   pinMode(ledPin, OUTPUT);
  8. }
  9. //next code on next page
  10.  
  11. void loop() {
  12.   buttonState =digitalRead(buttonPin);
  13.   // if button is pressed, the buttonState is HIGH:
  14.   if (buttonState == HIGH) {
  15.     // turn LED on:
  16.    digitalWrite(ledPin, HIGH);
  17.     delay(3000);
  18.   } else {
  19.     // turn LED off:
  20.     digitalWrite(ledPin, LOW);
  21.   }
  22.   delay(100);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement