IR sensor with Arduino and interface it with some components like an LED and a buzzer. We’ll make a setup where the LED lights up and the buzzer sounds when motion is detected by the IR sensor.
Components Needed.
1.Arduino board
2.IR sensor module
3.LED
4.Buzzer
5.Jumper wires
Wiring Connections:
Connect the VCC pin of the IR sensor module to the 5V pin of the Arduino.
Connect the GND pin of the IR sensor module to the GND pin of the Arduino.
Connect the OUT pin of the IR sensor module to digital pin 2 of the Arduino.
Connect the positive (anode) leg of the LED to digital pin 3 of the Arduino through a current-limiting resistor (220-330 ohms).
Connect the negative (cathode) leg of the LED to the GND pin of the Arduino.
Connect one terminal of the buzzer to digital pin 4 of the Arduino.
Connect the other terminal of the buzzer to the GND pin of the Arduino.
Code:
// Pin definitions
const int irSensorPin = 2;
const int ledPin = 3;
const int buzzerPin = 4;