1
\$\begingroup\$

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;
    }
}
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Transistor Feb 20 '16 at 21:57
  • \$\begingroup\$ 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? \$\endgroup\$ – Steve G Feb 20 '16 at 22:01
  • \$\begingroup\$ @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. \$\endgroup\$ – Passerby Feb 20 '16 at 22:29
1
\$\begingroup\$

The HC SR501 PIR module uses a BIS00001 PIR sensor IC. It has an active high output. When no motion is sensed, the output is pulled low, when motion is sensed, it's pulled high, through R14.

enter image description here

It is not active low, or open collector, unlike the SE-10 that the MBED Pir "Hello World" project is based on. You have a pull up enabled. Try disabling that to get it to work.

The SE-10 basically does the same, but has a NPN transistor at the IC's output, which inverts the logic at the Output pin. That does need the pull-up.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Hello thank you and sorry for the late reply. I have removed the pull up from the program and now the onboard LED just stays on and on moving my hand across the sensor its still on. \$\endgroup\$ – maltamash Mar 8 '16 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.