Created
March 2, 2018 17:34
-
-
Save anonymous/8f0be0ffb6366ebe814c6d9b0ef7cd49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int irmotionPin = 4; // Pin of IR Motion Sensor | |
int relayPin = 5; // Pin of Relay Module | |
void setup(){ | |
Serial.begin(9600); | |
pinMode(relayPin, OUTPUT); // Set Pin connected to Relay as an OUTPUT | |
digitalWrite(relayPin, LOW); // Set Pin to LOW to turn Relay OFF | |
} | |
void loop(){ | |
while (digitalRead(irmotionPin) == HIGH) { // If Motion detected | |
digitalWrite(relayPin, HIGH); // Turn Relay ON | |
Serial.println("Relay is ON"); | |
delay(10000); | |
} | |
digitalWrite(relayPin, LOW); // Turn Relay OFF | |
Serial.println("Relay is OFF"); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment