Test du terminal en entrée et en sortie. Commande d'une led au clavier.
Dependencies: mbed
main.cpp@0:551a0996336c, 2020-06-10 (annotated)
- Committer:
- gr91
- Date:
- Wed Jun 10 12:00:46 2020 +0000
- Revision:
- 0:551a0996336c
- Child:
- 1:b5706302e178
V1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gr91 | 0:551a0996336c | 1 | #include "mbed.h" |
gr91 | 0:551a0996336c | 2 | |
gr91 | 0:551a0996336c | 3 | Serial pc(PA_2, PA_3); |
gr91 | 0:551a0996336c | 4 | DigitalOut led(PA_15); |
gr91 | 0:551a0996336c | 5 | |
gr91 | 0:551a0996336c | 6 | int main() |
gr91 | 0:551a0996336c | 7 | { |
gr91 | 0:551a0996336c | 8 | pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); |
gr91 | 0:551a0996336c | 9 | led=1; |
gr91 | 0:551a0996336c | 10 | while(1) { |
gr91 | 0:551a0996336c | 11 | char c = pc.getc(); // Read hyperterminal |
gr91 | 0:551a0996336c | 12 | if (c == '0') { |
gr91 | 0:551a0996336c | 13 | led = 0; // OFF |
gr91 | 0:551a0996336c | 14 | } |
gr91 | 0:551a0996336c | 15 | if (c == '1') { |
gr91 | 0:551a0996336c | 16 | led = 1; // ON |
gr91 | 0:551a0996336c | 17 | } |
gr91 | 0:551a0996336c | 18 | } |
gr91 | 0:551a0996336c | 19 | } |