Materials:-
- Arduino uno = https://bit.ly/30v5XcY
- PIR motion sensor = https://bit.ly/30hBAIJ
- LED = https://bit.ly/39KeA8v
Diagram:-
Connections:-
PIR motion sensor to Arduino
- Pir VCC = Arduino 5V
- pir GND = Arduino GND
- Pir out = Arduino D8
LED to Arduino
- LED (+) = Arduino D13
- LED (-) = Arduino GND
Downloads:-
int led = 13;
int pir = 8;
void setup() {
pinMode(pir, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
int val =digitalRead(pir);
if(val== 1){
digitalWrite(led, HIGH);
}else{
digitalWrite(led, LOW);
}
}