Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:755a36a9fc5c
- Child:
- 1:41844163cb7f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Mar 23 22:47:55 2019 +0000 @@ -0,0 +1,65 @@ +#include "mbed.h" + + +Serial pc(USBTX, USBRX,9600); +Serial blue(PTC15, PTC14, 115200); //tx, rx +Serial other(PTC17, PTC16, 115200); +Ticker locker; + +char prev = 'z'; +char current = 'y'; +bool nflag = true; + +void lockCar() +{ + pc.printf("ticker\r\n\r"); + char send[] = "bj"; + if(nflag) + { + if(prev == current) + { + for(int i = 1; i< 50; i++){other.putc(send[1]);} + wait(5); + for(int i = 1; i< 50; i++){other.putc(send[0]);} + prev = 'z'; + nflag = false; + } + else + { + prev = current; + } + } +} + +int main() +{ + int i = 0; + int j = 0; + char hold[100] ="String"; + locker.attach(&lockCar, 15.0); + pc.printf(hold); + while (true) + { + while(blue.readable()) + { + hold[j++] = blue.getc(); + i = 10; + nflag = true; + } + + while(i) + { + hold[j] = '\0'; + other.putc(hold[0]); + current = hold[0]; + pc.printf("%d:", i); + pc.printf(hold); + pc.putc('\n'); + pc.putc('\r'); + i--; + } + + j = 0; + i=0; + } +} \ No newline at end of file