Dependencies:   mbed

main.cpp

Committer:
yu10078999
Date:
2016-08-27
Revision:
0:5d2615cbb0df

File content as of revision 0:5d2615cbb0df:

#include "mbed.h"
DigitalOut led(D2);
Serial pc(USBTX, USBRX);
char val;
int main() {
    pc.baud(9600);
    while(1) {
    if(pc.readable()) {
        pc.printf("Ready\n");
        val = pc.getc();
        if(val=='a'){
            led = 1 ;
            pc.printf("LED ON\n");
    } 
        else if (val == 'b') {
            led = 0;
            pc.printf("LED OFF\n");
    }
  }
}
}