Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. int irmotionPin = 4; //Pin of IR Motion Sensor
  2. int relayPin = 8; // Pin of Relay Module
  3.  
  4. void setup(){
  5. Serial.begin(9600);
  6. pinMode( relayPin, OUTPUT); // Set Pin connected to Relay as an OUTPUT
  7. digitalWrite(relayPin, LOW); // Set Pin to LOW to turn Relay OFF
  8. }
  9.  
  10. void loop(){
  11.  
  12. while (digitalRead (irmotionPin) == HIGH) { // If Motion detected
  13. digitalWrite(relayPin, HIGH); // Turn Relay ON
  14. Serial.println("Relay is ON");
  15. delay(120000);
  16. }
  17.  
  18. digitalWrite(relayPin, LOW); // Turn Relay OFF
  19. Serial.println("Relay is OFF");
  20. delay(500);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement