Test du terminal en entrée et en sortie. Commande d'une led au clavier.

Dependencies:   mbed

main.cpp

Committer:
gr91
Date:
2021-06-06
Revision:
1:b5706302e178
Parent:
0:551a0996336c

File content as of revision 1:b5706302e178:

#include "mbed.h"

Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut led(LED1);

int main()
{
    
    pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n");  // Write terminal
    led=1;
    while(1) {
        char c = pc.getc(); // Read hyperterminal
        if (c == '0') {
            led = 0; // OFF
        }
        if (c == '1') {
            led = 1; // ON
        }
    }
}