USB serial demo for an Android device See https://os.mbed.com/users/4180_1/notebook/using-mbed-with-an-android-phone-or-tablet/
See https://os.mbed.com/users/4180_1/notebook/using-mbed-with-an-android-phone-or-tablet/ for details
main.cpp@0:4236501a059a, 2018-02-08 (annotated)
- Committer:
- 4180_1
- Date:
- Thu Feb 08 14:58:45 2018 +0000
- Revision:
- 0:4236501a059a
ver 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:4236501a059a | 1 | #include "mbed.h" |
4180_1 | 0:4236501a059a | 2 | //Communicate with Android using USB serial |
4180_1 | 0:4236501a059a | 3 | //See https://os.mbed.com/users/4180_1/notebook/using-mbed-with-an-android-phone-or-tablet/ |
4180_1 | 0:4236501a059a | 4 | DigitalOut myled(LED1); |
4180_1 | 0:4236501a059a | 5 | Serial USB(USBTX,USBRX); |
4180_1 | 0:4236501a059a | 6 | |
4180_1 | 0:4236501a059a | 7 | int main() { |
4180_1 | 0:4236501a059a | 8 | USB.baud(19200); //set baud for Andriod App default |
4180_1 | 0:4236501a059a | 9 | wait(1.0); |
4180_1 | 0:4236501a059a | 10 | USB.printf("\n\rHello from mbed\n\r"); |
4180_1 | 0:4236501a059a | 11 | USB.printf("Type characters, hit send, and mbed will echo them back\n\r"); |
4180_1 | 0:4236501a059a | 12 | myled = 1; |
4180_1 | 0:4236501a059a | 13 | while(1) { |
4180_1 | 0:4236501a059a | 14 | USB.putc(USB.getc()); |
4180_1 | 0:4236501a059a | 15 | } |
4180_1 | 0:4236501a059a | 16 | } |