
Display a message on PC using UART
main.cpp@0:e0af24384f80, 2014-09-08 (annotated)
- Committer:
- jose_23991
- Date:
- Mon Sep 08 17:44:45 2014 +0000
- Revision:
- 0:e0af24384f80
Version 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jose_23991 | 0:e0af24384f80 | 1 | //////////////////////////////////////// |
jose_23991 | 0:e0af24384f80 | 2 | // Hyperterminal configuration // |
jose_23991 | 0:e0af24384f80 | 3 | // 9600 bauds, 8-bit data, no parity // |
jose_23991 | 0:e0af24384f80 | 4 | //////////////////////////////////////// |
jose_23991 | 0:e0af24384f80 | 5 | |
jose_23991 | 0:e0af24384f80 | 6 | #include "mbed.h" |
jose_23991 | 0:e0af24384f80 | 7 | |
jose_23991 | 0:e0af24384f80 | 8 | Serial serial(SERIAL_TX, SERIAL_RX); |
jose_23991 | 0:e0af24384f80 | 9 | DigitalOut myled(LED1); |
jose_23991 | 0:e0af24384f80 | 10 | |
jose_23991 | 0:e0af24384f80 | 11 | int main() |
jose_23991 | 0:e0af24384f80 | 12 | { |
jose_23991 | 0:e0af24384f80 | 13 | int i = 1; |
jose_23991 | 0:e0af24384f80 | 14 | |
jose_23991 | 0:e0af24384f80 | 15 | /* Print the serial header */ |
jose_23991 | 0:e0af24384f80 | 16 | serial.printf("\n"); |
jose_23991 | 0:e0af24384f80 | 17 | serial.printf("\n------------------------------------------------------"); |
jose_23991 | 0:e0af24384f80 | 18 | serial.printf("\n-- SERIAL --"); |
jose_23991 | 0:e0af24384f80 | 19 | serial.printf("\n------------------------------------------------------"); |
jose_23991 | 0:e0af24384f80 | 20 | serial.printf("\nHello World !"); |
jose_23991 | 0:e0af24384f80 | 21 | serial.printf("\n"); |
jose_23991 | 0:e0af24384f80 | 22 | |
jose_23991 | 0:e0af24384f80 | 23 | while(1) |
jose_23991 | 0:e0af24384f80 | 24 | { |
jose_23991 | 0:e0af24384f80 | 25 | wait(1); // Wait 1s |
jose_23991 | 0:e0af24384f80 | 26 | serial.printf("\n This program runs since %d seconds", i); // Show the counter (seconds) |
jose_23991 | 0:e0af24384f80 | 27 | myled = !myled; // Toggle the LED state |
jose_23991 | 0:e0af24384f80 | 28 | i++; // Increase the counter (seconds) |
jose_23991 | 0:e0af24384f80 | 29 | } |
jose_23991 | 0:e0af24384f80 | 30 | } |