fork 1

Dependencies:   mbed

Fork of eic_blinky_interrupt by 尚人 永井

main.cpp

Committer:
lelect
Date:
2014-05-20
Revision:
4:2b12ce3ec6b0
Parent:
3:50d8d4dc9ad6

File content as of revision 4:2b12ce3ec6b0:

#include "mbed.h"

Serial pc(USBTX,USBRX);//tx,rx
AnalogOut led_y(p18);

void pc_rx ()
{
    char buff=pc.getc();
    pc.putc(buff);
    if('A'<=buff&&buff<='Z') {
        pc.putc(buff+0x20);
    } else if('a'<=buff&&buff<='z') {
        pc.putc(buff-0x20);
    } else if('0'<=buff&&buff<='9') {
        float a=(buff-'0'+1)*0.1;//buff=='0'->a=0.1  buff=='9'->a=1.0
        led_y=a;
        pc.printf("led_y=%f\r\n",a);
    } else {
        pc.printf("a-z,A-Z,0-9 common!",a);        
    }
}

int main()
{
    pc.attach(&pc_rx,Serial::RxIrq);
    while(1) {
        sleep();
    }
}