Wataru Shibazaki
/
miniroboOK
minirobo OK tuusin
Diff: main.cpp
- Revision:
- 0:9b5fac6e0bae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 09 10:38:53 2020 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "string" + +RawSerial con(p28,p27,115200); +RawSerial pc (USBTX,USBRX,115200); +Ticker tras; +string tras_str = ""; +string USBtx_str = ""; + +char button; +void atras(){ + char con_c = con.getc(); + tras_str += con_c; + if(con_c == '\n'){ + USBtx_str = tras_str; + button = tras_str[0]; + tras_str = ""; + } +} +void aUSBtx(){ + //con.printf("LPCtras41\n"); + //pc.printf(USBtx_str.c_str()); + pc.printf("%d\n",int(button)); + +} +int main() +{ + tras.attach(&aUSBtx,0.5); + + con.attach(&atras,RawSerial::RxIrq); + while(1) { + if(button == 1){ + muki = 1; + speed = 100; + + saber1.putc(132); + saber1.putc(muki); + saber1.putc(speed); + saber1.putc( ( 132 + muki + speed ) & 127 ); + } + if(button == 2) { + muki = 0; + speed = 100; + + saber1.putc(132); + saber1.putc(muki); + saber1.putc(speed); + saber1.putc( ( 132 + muki + speed ) & 127 ); + } + }*/ + if(button == 8){ + pc.printf("8!!!!!!!!!!!"); + } + } +}