sample of getting console key

Dependencies:   mbed

Sample code of how to get key hit.
readable() function in Serial class can check buffer has data or not.

This could be equivalent to kbhit() function of DOS/Win environment.

main.cpp

Committer:
okano
Date:
2016-04-09
Revision:
0:06c67ac20cd3

File content as of revision 0:06c67ac20cd3:

#include "mbed.h"

Serial  pc( USBTX, USBRX );
BusOut  leds( LED4, LED3, LED2, LED1 );

int main()
{
    while (1) {
        if ( pc.readable() ) {
            leds    = pc.getc() - '0';
        }
    }
}