PIR Movement Sensor

Wiring up and using a PIR movement sensor is fairly simple. It is no different from the other sensors and components we have used – indeed it might be the simplest of all because it has a lot of the detail already coded into its own circuit.

In this case and looking at the back of the PIR we can see three pins (they aren’t labelled) – the first form the right is the 5v pin, the second is the Digital Output pin and third is the Ground pin (GND).

This is the opposite to most that are illustrated online. So be aware.

The code for using the PIR is nearly as simple as the others elements we’ve used you simply need;

pinMode(pirPin, INPUT);
digitalWrite(pirPin, LOW);

in the setup of your sketch and then this in your loop;

if(digitalRead(pirPin) == HIGH) {

and whatever you would like to do here (like light an LED)