Sybren Wubs
/
Minor_test_serial
Test exercise
Fork of Minor_test_serial by
main.cpp@1:15c5f4373ca5, 2016-09-12 (annotated)
- Committer:
- Sybren_Wubs
- Date:
- Mon Sep 12 10:03:39 2016 +0000
- Revision:
- 1:15c5f4373ca5
- Parent:
- 0:c8f15874531b
Serial_minor_exercise
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:c8f15874531b | 1 | #include "mbed.h" |
vsluiter | 0:c8f15874531b | 2 | |
Sybren_Wubs | 1:15c5f4373ca5 | 3 | DigitalOut myled(LED_RED); |
Sybren_Wubs | 1:15c5f4373ca5 | 4 | Serial pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 5 | |
vsluiter | 0:c8f15874531b | 6 | int main() |
vsluiter | 0:c8f15874531b | 7 | { |
vsluiter | 0:c8f15874531b | 8 | int i = 0; |
vsluiter | 0:c8f15874531b | 9 | pc.baud(115200); |
vsluiter | 0:c8f15874531b | 10 | pc.printf("Hello World!\n"); |
vsluiter | 0:c8f15874531b | 11 | |
vsluiter | 0:c8f15874531b | 12 | while (true) { |
vsluiter | 0:c8f15874531b | 13 | wait(0.5f); // wait a small period of time |
vsluiter | 0:c8f15874531b | 14 | pc.printf("%d \n", i); // print the value of variable i |
vsluiter | 0:c8f15874531b | 15 | i++; // increment the variable |
vsluiter | 0:c8f15874531b | 16 | myled = !myled; // toggle a led |
vsluiter | 0:c8f15874531b | 17 | } |
vsluiter | 0:c8f15874531b | 18 | } |