Controlling LED through terminal in PC

Dependencies:   mbed

main.cpp

Committer:
sivaieee
Date:
2016-11-14
Revision:
0:16598bc0eb44

File content as of revision 0:16598bc0eb44:

#include "mbed.h"
 
Serial pc(USBTX, USBRX); // tx, rx
DigitalOut led(LED1);
 
int main() {
 {   pc.printf("Press 'u' to turn off Led, 'd' to turn it on\n");
 
  while(1) {
        char c = pc.getc();
       pc.putc(c);
       if(c == 'u'){
           led = 1;
     }
       if(c == 'd') {
           led = 0;
       } 
 
    }
}
}