Enzo Grimeau
/
buffertest
test pour buffer
main.cpp@0:3aa4ba0ada56, 2020-10-23 (annotated)
- Committer:
- gr91
- Date:
- Fri Oct 23 13:51:26 2020 +0000
- Revision:
- 0:3aa4ba0ada56
- Child:
- 1:076e709173c9
Test led et terminal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gr91 | 0:3aa4ba0ada56 | 1 | #include "mbed.h" |
gr91 | 0:3aa4ba0ada56 | 2 | |
gr91 | 0:3aa4ba0ada56 | 3 | Serial pc(USBTX, USBRX); |
gr91 | 0:3aa4ba0ada56 | 4 | DigitalOut led(LED1); |
gr91 | 0:3aa4ba0ada56 | 5 | |
gr91 | 0:3aa4ba0ada56 | 6 | int main() |
gr91 | 0:3aa4ba0ada56 | 7 | { |
gr91 | 0:3aa4ba0ada56 | 8 | pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); |
gr91 | 0:3aa4ba0ada56 | 9 | led=1; |
gr91 | 0:3aa4ba0ada56 | 10 | while(1) { |
gr91 | 0:3aa4ba0ada56 | 11 | char c = pc.getc(); // Read hyperterminal |
gr91 | 0:3aa4ba0ada56 | 12 | if (c == '0') { |
gr91 | 0:3aa4ba0ada56 | 13 | led = 0; // OFF |
gr91 | 0:3aa4ba0ada56 | 14 | } |
gr91 | 0:3aa4ba0ada56 | 15 | if (c == '1') { |
gr91 | 0:3aa4ba0ada56 | 16 | led = 1; // ON |
gr91 | 0:3aa4ba0ada56 | 17 | } |
gr91 | 0:3aa4ba0ada56 | 18 | } |
gr91 | 0:3aa4ba0ada56 | 19 | } |