Advertisement
belrey10

PIR

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