Junaid Ashraf
/
Serial_HelloWorld_Mbed
sdsd
Fork of Serial_HelloWorld_Mbed by
Revision 1:6c338020fc53, committed 2018-07-23
- Comitter:
- JunaidAshraf
- Date:
- Mon Jul 23 13:21:03 2018 +0000
- Parent:
- 0:879aa9d0247b
- Commit message:
- o
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-src.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r 879aa9d0247b -r 6c338020fc53 main.cpp --- a/main.cpp Tue Feb 12 17:39:05 2013 +0000 +++ b/main.cpp Mon Jul 23 13:21:03 2018 +0000 @@ -1,10 +1,25 @@ #include "mbed.h" -Serial pc(USBTX, USBRX); // tx, rx +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); + +Serial pc(USBTX, USBRX); + +void callback() { + // Note: you need to actually read from the serial to clear the RX interrupt + printf("%c\n", pc.getc()); + char a=pc.getc(); + led3 = !led3; + printf("%c\n", a); + led2 = !led2; +} int main() { - pc.printf("Hello World!\n"); - while(1) { - pc.putc(pc.getc() + 1); + pc.attach(&callback); + + while (1) { + led1 = !led1; + wait(0.5); } } \ No newline at end of file
diff -r 879aa9d0247b -r 6c338020fc53 mbed-src.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Mon Jul 23 13:21:03 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#a11c0372f0ba