Nucleo_display_temp_LM35

Dependencies:   mbed

Committer:
anywill
Date:
Thu Oct 20 13:50:30 2016 +0000
Revision:
2:db3ce8717e38
Parent:
1:b78c70e272ae
PIR????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
anywill 1:b78c70e272ae 1 //平台nucleo 70r+mbed
anywill 2:db3ce8717e38 2 //Pir红外人体感应模块HC-SR501
anywill 2:db3ce8717e38 3 //感应人体后LED1亮
anywill 2:db3ce8717e38 4 // By www.emcu.it
anywill 2:db3ce8717e38 5 // Feb.2015
anywill 2:db3ce8717e38 6 // Tested on NUCLEO-F410RE
anywill 2:db3ce8717e38 7 //
anywill 0:a854d9a733ca 8 #include "mbed.h"
anywill 2:db3ce8717e38 9 DigitalOut myled(LED1);//D13
anywill 2:db3ce8717e38 10 DigitalIn Sensor(PA_10);
anywill 2:db3ce8717e38 11 int n=0;
anywill 0:a854d9a733ca 12 int main()
anywill 0:a854d9a733ca 13 {
anywill 2:db3ce8717e38 14 // 等待感应模块稳定(30 sec.)
anywill 2:db3ce8717e38 15 for (n=0; n<30; n++)
anywill 2:db3ce8717e38 16 {
anywill 2:db3ce8717e38 17 wait_ms(1000); // 1sec delay
anywill 2:db3ce8717e38 18
anywill 2:db3ce8717e38 19 myled = !myled; // Blinking LED1
anywill 2:db3ce8717e38 20 }
anywill 2:db3ce8717e38 21 myled = 0; // LED1 is OFF
anywill 2:db3ce8717e38 22
anywill 2:db3ce8717e38 23 while(1)
anywill 2:db3ce8717e38 24 {
anywill 2:db3ce8717e38 25 if (Sensor == 1)
anywill 2:db3ce8717e38 26 {
anywill 2:db3ce8717e38 27 myled = 1; // LED1 is ON
anywill 2:db3ce8717e38 28 wait_ms(20000); // LED1 亮 20 sec
anywill 2:db3ce8717e38 29 }
anywill 2:db3ce8717e38 30 else
anywill 2:db3ce8717e38 31 myled = 0; // LED1 灭
anywill 2:db3ce8717e38 32 }
anywill 2:db3ce8717e38 33 }