PIR Sensor Coding & Circuit Diagram
PIR SENSOR int pirPin = 12; //the digital pin connected to the PIR sensor's output int ledPin = 13; int motor = 8; int motor1 = 2; void setup(){ Serial.begin(9600); pinMode(pirPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(motor, OUTPUT); } void loop(){ if(digitalRead(pirPin) == HIGH){ digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state delay(50); digitalWrite(ledPin, LOW); delay(50); digitalWrite(motor, HIGH); } else{ digitalWrite(ledPin, LOW);//the led visualizes the sensors output pin state digitalWrite(motor, LOW); }}