Tutorial: How to use the PIR Sensor with ArduinoAugust 27, 2012

This tutorial, we will show how to use the PIR sensor  with your Arduino board. The Passive InfraRed is a device that detects infrared radiation, like heat. That sensor can activate an alarm when it detects a change in the infrared image. So, when a person moves in front of it, he/she can be detected.
The sensor has 3 wires: GND (brown), VCC (red) and Output (black). The following picture shows the connections:

This sensor needs a 10Kohm pull-up resistor. Now, upload the following code:

int pirPin = 2; //digital 2

int LedPin = 13;

void setup(){
pinMode(pirPin, INPUT);


void loop(){
int pirVal = digitalRead(pirPin);

if(pirVal == LOW){ //was motion detected







Ths PIR sets its output to low when some motion is detected. On this sample, when something moves in front of the sensor, the LED will turn on.

That's it!

Via: DFRobot, Source: GarageLab

2 thoughts on “Tutorial: How to use the PIR Sensor with Arduino”

Leave a Reply