Jorge Martin Beltran Avila
/
SensorPIR
PIR SENSOR HCSR501
Revision 0:820c81f96055, committed 2015-12-01
- Comitter:
- Jorge_Beltran
- Date:
- Tue Dec 01 23:45:42 2015 +0000
- Commit message:
- PIR Sensor HCSR 501
Changed in this revision
diff -r 000000000000 -r 820c81f96055 SensorPIR.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SensorPIR.cpp Tue Dec 01 23:45:42 2015 +0000 @@ -0,0 +1,52 @@ +#include "SensorPIR.h" + +/*Defines*/ +Serial UARTPIR(USBTX, USBRX); +DigitalOut dout(LED1); +DigitalIn enable1(D0); +//DigitalIn enable2(D1); +//DigitalIn enable3(D2); +//DigitalIn enable4(D3); + +/*Functions*/ +int GetPersonStatus(int RoomPrescence) { + bool print = 0; + bool RoomStatus = 0; + UARTPIR.baud(115200); + wait(2); //Wait for sensor to take snap shot of still room + + switch(RoomPrescence) + { + case 1: + if(enable1==1 /*|| enable2==1 || enable3==1 || enable4==1*/) + { + RoomStatus = 1; + dout=1; + if(print == 0) + { + UARTPIR.printf("Presencia detectada\n\r"); + print = 1; + } + } + else + { + RoomStatus = 0; + dout=0; + if(print == 1) + { + UARTPIR.printf("Ninguna presencia detectada\n\r"); + print = 0; + } + } + break; + + case 2: + /*ADD NEW ROOM*/ + break; + + default: + /*Do Nothing*/ + break; + } + return RoomStatus; +}
diff -r 000000000000 -r 820c81f96055 SensorPIR.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SensorPIR.h Tue Dec 01 23:45:42 2015 +0000 @@ -0,0 +1,8 @@ +#include "mbed.h" + +/*Extern Defines*/ + +/*Extern Variables*/ + +/*Extern Functions*/ +extern int GetPersonStatus(int RoomPrescence); \ No newline at end of file
diff -r 000000000000 -r 820c81f96055 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 01 23:45:42 2015 +0000 @@ -0,0 +1,9 @@ +#include "mbed.h" +#include "SensorPIR.h" + +int main() { + while(1) + { + GetPersonStatus(1); + } +}
diff -r 000000000000 -r 820c81f96055 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Dec 01 23:45:42 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file