wang tang
/
watersensor
LGZD:sensor
Diff: main.cpp
- Revision:
- 0:1bf4445f640f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 27 08:23:58 2017 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +DigitalOut ledpin(LED1); +DigitalIn sensor_in(D4); +Serial serial(USBTX, USBRX); +int main(){ + + while(1) { + // LEDs are ON + if(sensor_in) + { + ledpin = 1; + serial.printf("LED:ON\n"); + wait(1.2); + } + else + { + // LEDs are OFF + ledpin = 0; + serial.printf("LED:OFF\n"); + wait(1.4); + } + } +} \ No newline at end of file