2019NHK_teamA / Mbed 2 deprecated 2019KoRobo

Dependencies:   mbed

Committer:
st17099ng
Date:
Tue Mar 05 09:18:07 2019 +0000
Revision:
0:bba4760cb391
Child:
1:72b8490a4ece
2019KoRobo; (tuyotuyo)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
st17099ng 0:bba4760cb391 1 #include "mbed.h"
st17099ng 0:bba4760cb391 2 #include "Help.h"
st17099ng 0:bba4760cb391 3
st17099ng 0:bba4760cb391 4 Serial pc(USBTX,USBRX);
st17099ng 0:bba4760cb391 5 DigitalOut POWER_LED(D5);
st17099ng 0:bba4760cb391 6
st17099ng 0:bba4760cb391 7 int direct,speed;
st17099ng 0:bba4760cb391 8 int Raxis[2],Laxis[2];
st17099ng 0:bba4760cb391 9 char Rfmot,Lfmot;
st17099ng 0:bba4760cb391 10 char Rbmot,Lbmot;
st17099ng 0:bba4760cb391 11 char mot1,air1;
st17099ng 0:bba4760cb391 12
st17099ng 0:bba4760cb391 13 int main(void)
st17099ng 0:bba4760cb391 14 {
st17099ng 0:bba4760cb391 15 speed = fast;
st17099ng 0:bba4760cb391 16 direct = sb;
st17099ng 0:bba4760cb391 17 format_data(&Rfmot);
st17099ng 0:bba4760cb391 18 format_data(&Lfmot);
st17099ng 0:bba4760cb391 19 format_data(&Rbmot);
st17099ng 0:bba4760cb391 20 format_data(&Lbmot);
st17099ng 0:bba4760cb391 21 format_data(&mot1);
st17099ng 0:bba4760cb391 22 format_data(&air1);
st17099ng 0:bba4760cb391 23 POWER_LED = 1;
st17099ng 0:bba4760cb391 24 while(1) {
st17099ng 0:bba4760cb391 25 get_stick(Raxis,'R');
st17099ng 0:bba4760cb391 26 get_stick(Laxis,'L');
st17099ng 0:bba4760cb391 27 speed = set_speed(speed);
st17099ng 0:bba4760cb391 28 direct = set_direct(Raxis, Laxis);
st17099ng 0:bba4760cb391 29
st17099ng 0:bba4760cb391 30 set_emg();
st17099ng 0:bba4760cb391 31 if(direct != 0) {
st17099ng 0:bba4760cb391 32 set_tire(&Rfmot, &Rbmot, direct, 'R', speed);
st17099ng 0:bba4760cb391 33 set_tire(&Lfmot, &Lbmot, direct, 'L', speed);
st17099ng 0:bba4760cb391 34 } else {
st17099ng 0:bba4760cb391 35 set_slide(&Rfmot,&Lfmot,&Rbmot,&Lbmot,r1,l1, speed);
st17099ng 0:bba4760cb391 36 }
st17099ng 0:bba4760cb391 37 write_data(Rfmotadd,Rfmot);
st17099ng 0:bba4760cb391 38 write_data(Lfmotadd,Lfmot);
st17099ng 0:bba4760cb391 39 write_data(Rbmotadd,Rbmot);
st17099ng 0:bba4760cb391 40 write_data(Lbmotadd,Lbmot);
st17099ng 0:bba4760cb391 41 write_data(Lbmotadd,Lbmot);
st17099ng 0:bba4760cb391 42
st17099ng 0:bba4760cb391 43
st17099ng 0:bba4760cb391 44 pri("\033[2J\033[1;1H RX:%d",Raxis[0]);
st17099ng 0:bba4760cb391 45 pri("\033[2;1H RY:%d",Raxis[1]);
st17099ng 0:bba4760cb391 46 pri("\033[3;1H LX:%d",Laxis[0]);
st17099ng 0:bba4760cb391 47 pri("\033[4;1H LY:%d",Laxis[1]);
st17099ng 0:bba4760cb391 48 pri("\033[5;1H Rfmot:0x%x",Rfmot);
st17099ng 0:bba4760cb391 49 pri("\033[6;1H Lfmot:0x%x",Lfmot);
st17099ng 0:bba4760cb391 50 pri("\033[7;1H Rbmot:0x%x",Rbmot);
st17099ng 0:bba4760cb391 51 pri("\033[8;1H Lbmot:0x%x",Lbmot);
st17099ng 0:bba4760cb391 52 pri("\033[9;1H direct:%d",direct);
st17099ng 0:bba4760cb391 53 pri("\033[10;1H speed:%d",speed);
st17099ng 0:bba4760cb391 54 }
st17099ng 0:bba4760cb391 55 }