![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Test du terminal en entrée et en sortie. Commande d'une led au clavier.
Dependencies: mbed
main.cpp@1:b5706302e178, 2021-06-06 (annotated)
- Committer:
- gr91
- Date:
- Sun Jun 06 20:29:00 2021 +0000
- Revision:
- 1:b5706302e178
- Parent:
- 0:551a0996336c
xx;
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 | 1:b5706302e178 | 3 | Serial pc(SERIAL_TX, SERIAL_RX); |
gr91 | 1:b5706302e178 | 4 | DigitalOut led(LED1); |
gr91 | 0:551a0996336c | 5 | |
gr91 | 0:551a0996336c | 6 | int main() |
gr91 | 0:551a0996336c | 7 | { |
gr91 | 1:b5706302e178 | 8 | |
gr91 | 1:b5706302e178 | 9 | pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); // Write terminal |
gr91 | 0:551a0996336c | 10 | led=1; |
gr91 | 0:551a0996336c | 11 | while(1) { |
gr91 | 0:551a0996336c | 12 | char c = pc.getc(); // Read hyperterminal |
gr91 | 0:551a0996336c | 13 | if (c == '0') { |
gr91 | 0:551a0996336c | 14 | led = 0; // OFF |
gr91 | 0:551a0996336c | 15 | } |
gr91 | 0:551a0996336c | 16 | if (c == '1') { |
gr91 | 0:551a0996336c | 17 | led = 1; // ON |
gr91 | 0:551a0996336c | 18 | } |
gr91 | 0:551a0996336c | 19 | } |
gr91 | 0:551a0996336c | 20 | } |