Proximity alarm with flags to stop the buzzer or reset the range finder
Dependencies: mbed
Fork of SerialPassthroughcjsESP8266 by
Diff: main.cpp
- Revision:
- 6:dc4c165f6b53
- Parent:
- 5:96cb82af9996
- Child:
- 7:d78ed22a787d
diff -r 96cb82af9996 -r dc4c165f6b53 main.cpp --- a/main.cpp Thu Apr 30 22:48:21 2015 +0000 +++ b/main.cpp Tue Jun 07 16:19:17 2016 +0000 @@ -1,9 +1,10 @@ #include "mbed.h" RawSerial pc(USBTX, USBRX); -RawSerial dev(D1, D0); +RawSerial dev(p28,p27); DigitalOut led1(LED1); DigitalOut led4(LED4); +DigitalOut rst(p26); void dev_recv() { @@ -15,19 +16,32 @@ void pc_recv() { + char c; led4 = !led4; while(pc.readable()) { - dev.putc(pc.getc()); + c=pc.getc(); + dev.putc(c); + //pc.putc(c); // echo back + if(c==13) {dev.putc(10); + pc.putc(10); + } } } int main() { - pc.baud(9600); - dev.baud(9600); + rst=0; + wait(1); + rst=1; + wait(1); + pc.printf("go\n\r"); + pc.baud(115200); + dev.baud(115200); pc.attach(&pc_recv, Serial::RxIrq); dev.attach(&dev_recv, Serial::RxIrq); + + while(1) { sleep();