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