red/power 5v/39 white/gnd/1 signal/black/19 use MBED stand alone ONLY ok seems to take the LED a long time to turn off - why? http://bildr.org/2011/06/pir_arduino/

Dependencies:   mbed

Committer:
avnisha
Date:
Wed Feb 19 04:54:12 2014 +0000
Revision:
0:c3ab9adf1295
ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
avnisha 0:c3ab9adf1295 1 #include "mbed.h"
avnisha 0:c3ab9adf1295 2
avnisha 0:c3ab9adf1295 3 /*
avnisha 0:c3ab9adf1295 4 * Test the motion sensor
avnisha 0:c3ab9adf1295 5 */
avnisha 0:c3ab9adf1295 6
avnisha 0:c3ab9adf1295 7
avnisha 0:c3ab9adf1295 8 DigitalOut LED(LED1);
avnisha 0:c3ab9adf1295 9 DigitalIn PIR(p19);
avnisha 0:c3ab9adf1295 10
avnisha 0:c3ab9adf1295 11
avnisha 0:c3ab9adf1295 12 int main() {
avnisha 0:c3ab9adf1295 13
avnisha 0:c3ab9adf1295 14 PIR.mode(PullUp);
avnisha 0:c3ab9adf1295 15 LED = 0;
avnisha 0:c3ab9adf1295 16
avnisha 0:c3ab9adf1295 17 while(1) {
avnisha 0:c3ab9adf1295 18 //printf("PIR %d \r\n", (int)PIR);
avnisha 0:c3ab9adf1295 19 if (!PIR){
avnisha 0:c3ab9adf1295 20 LED=1;
avnisha 0:c3ab9adf1295 21 wait(1.0);
avnisha 0:c3ab9adf1295 22 }else{
avnisha 0:c3ab9adf1295 23 LED=0;
avnisha 0:c3ab9adf1295 24 }
avnisha 0:c3ab9adf1295 25
avnisha 0:c3ab9adf1295 26 }
avnisha 0:c3ab9adf1295 27 }
avnisha 0:c3ab9adf1295 28