minirobo OK tuusin

Dependencies:   mbed

main.cpp

Committer:
shibazakiwataru
Date:
2020-10-09
Revision:
0:9b5fac6e0bae

File content as of revision 0:9b5fac6e0bae:

#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!!!!!!!!!!!");
        }
    }
}