Gerardo Carmona
/
MSE_Serial
Serial communication
main.cpp@0:ef5992a8b537, 2014-11-24 (annotated)
- Committer:
- gcarmonar
- Date:
- Mon Nov 24 23:09:16 2014 +0000
- Revision:
- 0:ef5992a8b537
Serial communication
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gcarmonar | 0:ef5992a8b537 | 1 | #include "mbed.h" |
gcarmonar | 0:ef5992a8b537 | 2 | |
gcarmonar | 0:ef5992a8b537 | 3 | DigitalOut myled(LED_GREEN); |
gcarmonar | 0:ef5992a8b537 | 4 | Serial pc(USBTX, USBRX); |
gcarmonar | 0:ef5992a8b537 | 5 | |
gcarmonar | 0:ef5992a8b537 | 6 | int main() |
gcarmonar | 0:ef5992a8b537 | 7 | { |
gcarmonar | 0:ef5992a8b537 | 8 | int i = 0; |
gcarmonar | 0:ef5992a8b537 | 9 | pc.printf("Hello World!\n"); |
gcarmonar | 0:ef5992a8b537 | 10 | |
gcarmonar | 0:ef5992a8b537 | 11 | while (true) { |
gcarmonar | 0:ef5992a8b537 | 12 | wait(0.5f); // wait a small period of time |
gcarmonar | 0:ef5992a8b537 | 13 | pc.printf("%d \n", i); // print the value of variable i |
gcarmonar | 0:ef5992a8b537 | 14 | i++; // increment the variable |
gcarmonar | 0:ef5992a8b537 | 15 | myled = !myled; // toggle a led |
gcarmonar | 0:ef5992a8b537 | 16 | } |
gcarmonar | 0:ef5992a8b537 | 17 | } |