# PIR sensor not working

I am new to electronics and microcontrollers. I am using an LPC1768 and a hc sr501 PIR sensor to create a simple motion detector. I have connected the pins of the PIR sensor to the breadboard and the lpc1768. I have imported the code from the mbed library however on moving my hand across the sensor the led does not light up.

#include "mbed.h"

DigitalOut led1(LED1);
DigitalIn alarm(p29, PullUp); //internal pull up

int main() {
wait(2);

while(1) {
if (!alarm){
led1=1;
wait(2);
}
else
led1=0;
}
}

• Welcome to SE. You need to check if the sensor is working. You can use a volt or multimeter for this or wire up a resistor and LED to the output of the sensor. Please put links to datasheets for all the devices so we don't all have to search the web for them. Your "wait(2)" command is probably 2 ms. This may be too quick to see. There's a schematic button on the editor toolbar. Add a schematic. – Transistor Feb 20 '16 at 21:57
• Lots of questions: What power supply are you using for the SR501? It must be at least 5V. Do you have the lens fitted? Do you have the light sensor (CDS2) fitted to the board? – Steve G Feb 20 '16 at 22:01
• @transistor the default on time for the PIR sensor would be seconds, so the wait() doesn't really matter. It would be polling as true enough that the led should be seen. – Passerby Feb 20 '16 at 22:29