Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 /* 00004 00005 By: www.emcu.eu 00006 Date: April 2018 00007 Components: NUCLEO-L011K4 + PANASONIC PIR EKMC1603111 00008 Connections: 00009 00010 PIR VCC -> PB_4 00011 PIR Signal -> PB_5 00012 PIR GND -> PA_11 00013 00014 Buzzer Vcc -> PA_9 00015 Buzzer GND -> GND of NUCLEO-L011K4 00016 00017 ATTENTION: 00018 For use the NUCLEO-L011K4 with an external power supply, you must do a tin soldering on JP1. 00019 See the NUCLEO-L011K4 datasheet at pg.11 00020 http://www.st.com/content/ccc/resource/technical/document/user_manual/e3/0e/88/05/e8/74/43/a0/DM00231744.pdf/files/DM00231744.pdf/jcr:content/translations/en.DM00231744.pdf 00021 00022 NUCLEO-L011K4 is available from here: 00023 *** http://www.newark.com/stmicroelectronics/nucleo-l011k4/dev-board-nucleo-32-mcu/dp/81Y3973?ost=NUCLEO-L011K4&ddkey=http%3Aen-US%2FElement14_US%2Fsearch 00024 *** https://www.mouser.it/ProductDetail/STMicroelectronics/NUCLEO-L011K4?qs=%2fha2pyFaduhQJSbhHAGqiYkL%252bo2vgvfhlGVOMPt1G42J4HVOM%2fj23Q%3d%3d 00025 00026 PANASONIC PIR EKMC1603111 is available from here: 00027 *** http://www.newark.com/panasonic-electric-works/ekmc1603111/pir-motion-sensor-digital-3vdc/dp/26T3945 00028 *** https://www.mouser.it/ProductDetail/Panasonic/EKMC1603111/?qs=sGAEpiMZZMvhQj7WZhFIAJaM7IUEh%252bHgM6uLDBL6vt0=&gclid=Cj0KCQjwhoLWBRD9ARIsADIRaxR7KH6LCSsPG5aDS1dEvlALL-ijmg-nd1XuzC_C1-15QGecG8rKbckaAn7AEALw_wcB 00029 00030 00031 */ 00032 00033 DigitalOut myLed(PB_3); 00034 DigitalOut myRelay(PB_4); 00035 DigitalIn ReadPB(PA_2); // READ PIR status 00036 00037 00038 00039 00040 00041 int main() 00042 { 00043 myLed = 0; 00044 myRelay = 0; 00045 bool oneShot = false; 00046 00047 // Configure PIR SIGNAL, GND and VCC 00048 ReadPB.mode(PullUp); 00049 00050 00051 while(1) 00052 { 00053 // Check State 00054 if (oneShot==true) 00055 { 00056 wait(1); 00057 myRelay= 1; 00058 wait(7); 00059 myRelay= 0; 00060 oneShot=false; 00061 } 00062 else 00063 { 00064 if (ReadPB == 0) // Check PB 00065 { 00066 wait(.2); 00067 if (ReadPB == 0) 00068 { 00069 oneShot=true; 00070 } 00071 } 00072 } 00073 myLed=ReadPB; 00074 } 00075 }
Generated on Mon Oct 31 2022 08:01:43 by
1.7.2