Components and supplies
Arduino UNO
Project description
Code
code
c_cpp
1int irmotionPin = 4; // Pin of IR Motion 2Sensorint relayPin = 8; // Pin of Relay Module 3void setup(){ Serial.begin(9600); 4pinMode(relayPin, OUTPUT); // Set Pin connected to Relay as an OUTPUT 5digitalWrite(relayPin, LOW); // Set Pin to LOW to turn Relay OFF 6} 7void loop(){ 8 while (digitalRead(irmotionPin) == HIGH) 9 { // If Motion detected 10 11 digitalWrite(relayPin, HIGH); // Turn Relay ON 12 Serial.println("Relay is ON"); 13 delay(15000);} 14 digitalWrite(relayPin, LOW); // Turn Relay OFF 15 Serial.println("Relay is OFF"); 16 delay(500); }
Comments
Only logged in users can leave comments