led toggle en dingen printen naar pc
Dependencies: mbed Minor_test_serial MODSERIAL
main.cpp@3:6339bc90369a, 2019-10-07 (annotated)
- Committer:
- JasperFix
- Date:
- Mon Oct 07 10:07:50 2019 +0000
- Revision:
- 3:6339bc90369a
- Parent:
- 2:2aa3c9a2a838
led toggles;
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 | |
vsluiter | 0:c8f15874531b | 4 | DigitalOut myled(LED_GREEN); |
vsluiter | 0:c8f15874531b | 5 | MODSERIAL pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 6 | |
JasperFix | 2:2aa3c9a2a838 | 7 | |
vsluiter | 0:c8f15874531b | 8 | int main() |
vsluiter | 0:c8f15874531b | 9 | { |
vsluiter | 0:c8f15874531b | 10 | pc.baud(115200); |
JasperFix | 2:2aa3c9a2a838 | 11 | myled = 1; |
JasperFix | 2:2aa3c9a2a838 | 12 | pc.printf("\r\nBoard reset, start again\r\n"); |
JasperFix | 2:2aa3c9a2a838 | 13 | |
vsluiter | 0:c8f15874531b | 14 | while (true) { |
JasperFix | 2:2aa3c9a2a838 | 15 | wait(0.05f); // wait a small period of time |
JasperFix | 2:2aa3c9a2a838 | 16 | char c; |
JasperFix | 2:2aa3c9a2a838 | 17 | c = pc.getc(); |
JasperFix | 2:2aa3c9a2a838 | 18 | if(pc.getc()){ |
JasperFix | 2:2aa3c9a2a838 | 19 | myled = !myled; // toggle a led |
JasperFix | 2:2aa3c9a2a838 | 20 | pc.printf("\r%c\r\n",c); |
JasperFix | 2:2aa3c9a2a838 | 21 | } |
JasperFix | 2:2aa3c9a2a838 | 22 | else{ |
JasperFix | 2:2aa3c9a2a838 | 23 | } |
JasperFix | 2:2aa3c9a2a838 | 24 | |
vsluiter | 0:c8f15874531b | 25 | } |
vsluiter | 0:c8f15874531b | 26 | } |