tetsuya Ogata
/
Enpra_practice08
Diff: main.cpp
- Revision:
- 0:f7ffea7d552c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 06 06:19:11 2013 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "Serial.h" + +Serial usbSerial(USBTX, USBRX); + +DigitalOut leds[4] = {LED1, LED2, LED3, LED4}; + +int main() { + usbSerial.printf("Hello World!"); + while(1) { + char c = usbSerial.getc(); + switch(c) { + case '1': + leds[0] = 1; + break; + case '2': + leds[1] = 1; + break; + case '3': + leds[2] = 1; + break; + case '4': + leds[3] = 1; + break; + default: + leds[0] = 0; + leds[1] = 0; + leds[2] = 0; + leds[3] = 0; + break; + } + } +}