w mx
/
sensors3
sr501/BH1750/mq-2/dht11
Fork of sensors_2 by
Diff: example.cpp
- Revision:
- 2:cd0ea77c7d66
- Parent:
- 1:1197997ae0ea
- Child:
- 3:31aec950f7dc
--- a/example.cpp Wed Sep 12 15:51:26 2018 +0000 +++ b/example.cpp Thu Sep 13 05:52:55 2018 +0000 @@ -11,6 +11,7 @@ usb2pc.printf("starting\r\n"); sr501 x(PB_1); BH1750 y(PB_7,PB_6); + mq z(PA_7,PA_6); while(1) { @@ -28,8 +29,25 @@ } wait(0.1); */ - + /* float light=y.getlightdata(); usb2pc.printf("Light intensity: %.4f Lux\r\n",light); + */ + + if(z.operator==(true)) + { + usb2pc.printf("mq on\r\n"); + while(!z.read()){usb2pc.printf("aaaaaaaaaaaaa\r\n");wait(0.1);myled=1;} + myled = 1; // LED is ON + wait(0.2); // 200 ms + z.reset(); + } + else + { + usb2pc.printf("mq off\r\n"); + myled = 0; // LED is OFF + wait(1.0); // 1 sec + } + } } \ No newline at end of file