Advertisement
cisco404

Program Sederhana Sensor PIR

Mar 18th, 2024
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <Arduino.h>
  2.  
  3. // -------------------------------------------
  4. // Program Sederhana Sensor PIR
  5. // www.ardukode.blogspot.com
  6. // -------------------------------------------
  7.  
  8. int ledPin = 13;
  9. int pirPin = 2;
  10.  
  11. void setup() {
  12.   pinMode(ledPin, OUTPUT);
  13.   pinMode(pirPin, INPUT);
  14. }
  15.  
  16. void loop() {
  17.   int pirValue = digitalRead(pirPin);
  18.  
  19.   if (pirValue == HIGH) {
  20.     digitalWrite(ledPin, HIGH);
  21.   } else {
  22.     digitalWrite(ledPin, LOW);
  23.   }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement