Read hyper-terminal

Dependencies:   mbed

Committer:
bcostm
Date:
Wed Jun 21 17:53:41 2017 +0000
Revision:
0:aabe1b05abb9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:aabe1b05abb9 1 #include "mbed.h"
bcostm 0:aabe1b05abb9 2
bcostm 0:aabe1b05abb9 3 Serial pc(SERIAL_TX, SERIAL_RX);
bcostm 0:aabe1b05abb9 4 DigitalOut led(LED1);
bcostm 0:aabe1b05abb9 5
bcostm 0:aabe1b05abb9 6 int main()
bcostm 0:aabe1b05abb9 7 {
bcostm 0:aabe1b05abb9 8 pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n");
bcostm 0:aabe1b05abb9 9 while(1) {
bcostm 0:aabe1b05abb9 10 char c = pc.getc(); // Read hyperterminal
bcostm 0:aabe1b05abb9 11 if (c == '0') {
bcostm 0:aabe1b05abb9 12 led = 0; // OFF
bcostm 0:aabe1b05abb9 13 }
bcostm 0:aabe1b05abb9 14 if (c == '1') {
bcostm 0:aabe1b05abb9 15 led = 1; // ON
bcostm 0:aabe1b05abb9 16 }
bcostm 0:aabe1b05abb9 17 }
bcostm 0:aabe1b05abb9 18 }