Advertisement
andretafta

LED + Button Test Ardunino

Oct 16th, 2023
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // C++ code
  2. //
  3.  
  4. int pin_led = 9;
  5. int pin_button = 2;
  6. int posisi_button;
  7. void setup()
  8. {
  9.   pinMode (pin_led, OUTPUT);
  10.   pinMode (pin_button, INPUT);
  11. }
  12.  
  13. void loop()
  14. {
  15.   posisi_button = digitalRead (pin_button);
  16.   if (posisi_button == LOW)
  17.     {
  18.         digitalWrite(pin_led, HIGH);
  19.     }
  20.   else
  21.     {
  22.         digitalWrite(pin_led, LOW);
  23.     }
  24.   delay(10); // Delay a little bit to improve simulation performance
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement