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.

Committer:
okano
Date:
Sat Apr 09 08:08:16 2016 +0000
Revision:
0:06c67ac20cd3
initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:06c67ac20cd3 1 #include "mbed.h"
okano 0:06c67ac20cd3 2
okano 0:06c67ac20cd3 3 Serial pc( USBTX, USBRX );
okano 0:06c67ac20cd3 4 BusOut leds( LED4, LED3, LED2, LED1 );
okano 0:06c67ac20cd3 5
okano 0:06c67ac20cd3 6 int main()
okano 0:06c67ac20cd3 7 {
okano 0:06c67ac20cd3 8 while (1) {
okano 0:06c67ac20cd3 9 if ( pc.readable() ) {
okano 0:06c67ac20cd3 10 leds = pc.getc() - '0';
okano 0:06c67ac20cd3 11 }
okano 0:06c67ac20cd3 12 }
okano 0:06c67ac20cd3 13 }