Light is blue and toggles after pressing key.
Fork of Minor_test_serial by
main.cpp@3:c50d01e1dbc5, 2018-09-11 (annotated)
- Committer:
- MAHCSnijders
- Date:
- Tue Sep 11 13:46:18 2018 +0000
- Revision:
- 3:c50d01e1dbc5
- Parent:
- 2:6dd2840ac8d0
LED is BLUE instead of GREEN.
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 | #include "MODSERIAL.h" |
vsluiter | 0:c8f15874531b | 3 | |
MAHCSnijders | 3:c50d01e1dbc5 | 4 | DigitalOut myled(LED_BLUE); |
vsluiter | 0:c8f15874531b | 5 | MODSERIAL pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 6 | |
MAHCSnijders | 2:6dd2840ac8d0 | 7 | char c; |
MAHCSnijders | 2:6dd2840ac8d0 | 8 | |
vsluiter | 0:c8f15874531b | 9 | int main() |
vsluiter | 0:c8f15874531b | 10 | { |
vsluiter | 0:c8f15874531b | 11 | int i = 0; |
vsluiter | 0:c8f15874531b | 12 | pc.baud(115200); |
MAHCSnijders | 2:6dd2840ac8d0 | 13 | c = pc.getc(); |
MAHCSnijders | 2:6dd2840ac8d0 | 14 | pc.printf("Pressed Key: %c\n",c); |
vsluiter | 0:c8f15874531b | 15 | |
vsluiter | 0:c8f15874531b | 16 | while (true) { |
vsluiter | 0:c8f15874531b | 17 | wait(0.5f); // wait a small period of time |
MAHCSnijders | 2:6dd2840ac8d0 | 18 | // pc.printf("%d \r\n", i); // print the value of variable i |
vsluiter | 0:c8f15874531b | 19 | i++; // increment the variable |
vsluiter | 0:c8f15874531b | 20 | myled = !myled; // toggle a led |
vsluiter | 0:c8f15874531b | 21 | } |
vsluiter | 0:c8f15874531b | 22 | } |