Proximity alarm with flags to stop the buzzer or reset the range finder
Dependencies: mbed
Fork of SerialPassthroughcjsESP8266 by
Diff: main.cpp
- Revision:
- 8:34cc66421054
- Parent:
- 7:d78ed22a787d
- Child:
- 9:b1344ca3497d
--- a/main.cpp Tue Jun 07 19:37:59 2016 +0000 +++ b/main.cpp Wed Jun 08 09:14:56 2016 +0000 @@ -6,10 +6,11 @@ #include "mbed.h" RawSerial pc(USBTX, USBRX); // serial terminal for the pc connection +//RawSerial dev(PTE0,PTE1); // for KL25Z... asuming one can't use the PTA1 version which is the stdio RawSerial dev(p28,p27); // serial uart for connecting to the esp8266 tx,rx NB mbed tx must connect ot esp rx and vice versa DigitalOut led1(LED1); // twp leds DigitalOut led4(LED4); // to allow visual check of bidirectional comms -DigitalOut rst(p26); +DigitalOut rst(p26); // single digital pin to drive the esp8266 reset line // subroutine to run anytime a serial interrupt arrives from the device // this basically passes everything thatthe device produces on to the pc terminal screen @@ -42,18 +43,19 @@ { rst=0; wait(1); - rst=1; + rst=1; // send the esp8266 reset wait(1); - pc.printf("go\n\r"); - pc.baud(115200); + pc.printf("ok off we go....\n\r"); + + pc.baud(115200); // NB maybe this should go before this dev.baud(115200); - pc.attach(&pc_recv, Serial::RxIrq); + pc.attach(&pc_recv, Serial::RxIrq); // attach the two interrupt services dev.attach(&dev_recv, Serial::RxIrq); while(1) { - sleep(); + sleep(); // so for KL25z this is probably wrong.... but not yet tested 07-06-2016 } }