Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:518fb998d26f, 2017-10-04 (annotated)
- Committer:
- santifs
- Date:
- Wed Oct 04 14:56:31 2017 +0000
- Revision:
- 0:518fb998d26f
Read and write in terminal. LED blinks.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
santifs | 0:518fb998d26f | 1 | #include "mbed.h" |
santifs | 0:518fb998d26f | 2 | |
santifs | 0:518fb998d26f | 3 | Serial pc(SERIAL_TX, SERIAL_RX); |
santifs | 0:518fb998d26f | 4 | DigitalOut led(LED1); |
santifs | 0:518fb998d26f | 5 | |
santifs | 0:518fb998d26f | 6 | int main() |
santifs | 0:518fb998d26f | 7 | { |
santifs | 0:518fb998d26f | 8 | pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); |
santifs | 0:518fb998d26f | 9 | while(1) { |
santifs | 0:518fb998d26f | 10 | char c = pc.getc(); // Read hyperterminal |
santifs | 0:518fb998d26f | 11 | pc.printf("%c", c); //Write character in Terminal |
santifs | 0:518fb998d26f | 12 | if (c == '0') { |
santifs | 0:518fb998d26f | 13 | led = 0; // OFF |
santifs | 0:518fb998d26f | 14 | } |
santifs | 0:518fb998d26f | 15 | if (c == '1') { |
santifs | 0:518fb998d26f | 16 | led = 1; // ON |
santifs | 0:518fb998d26f | 17 | } |
santifs | 0:518fb998d26f | 18 | } |
santifs | 0:518fb998d26f | 19 | } |