Advertisement
belrey10

Untitled

Sep 2nd, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. int ledBuzz = 13;
  2. int reedSwitch = 2;
  3. int switchState;
  4.  
  5. void setup() {
  6.   // put your setup code here, to run once:
  7. pinMode (ledBuzz, OUTPUT);
  8. pinMode (reedSwitch, INPUT);
  9.  
  10. }
  11.  
  12. void loop() {
  13.  
  14. switchState = digitalRead(reedSwitch);
  15.  
  16. if (switchState == HIGH)
  17. {
  18.      digitalWrite(ledBuzz, HIGH);
  19. }
  20.  
  21. else
  22. {
  23.   digitalWrite(ledBuzz, LOW);
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement