aaa

Dependencies:   mbed

main.cpp

Committer:
turnip
Date:
2019-06-01
Revision:
0:9aec4ef78a5a

File content as of revision 0:9aec4ef78a5a:

#include "mbed.h"
/*
DigitalIn l1(PA_7,PullUp);
DigitalIn l2(PA_6,PullUp);
DigitalIn r1(PF_1,PullUp);
DigitalIn r2(PA_0,PullUp);
DigitalIn s1(PA_4,PullUp);
DigitalIn s2(PA_1,PullUp);
DigitalIn horyuu(PA_3,PullUp);
*/

PwmOut left1(PA_12);
PwmOut left2(PB_0);
PwmOut right1(PA_8);
PwmOut right2(PF_0);
/*
PwmOut servo1(PA_11);
PwmOut servo2(PB_5);
*/
float max=0.7;

int main()
{
    while(1) {

        right1=0.6;
        right2=0;
        left1=0.6;
        left2=0;
    
        /*if(l1.read()==0){
            wait(0.05);
            if(l1.read()==0){
            left1=max;
            left2=0;
            }
        }
        if(l2.read()==0){
            wait(0.05);
            if(l2.read()==0){
            left1=0;
            left2=max;
            }
        }
        if(r1.read()==0){
            wait(0.05);
            if(r1.read()==0){
            right1=max;
            right2=0;
            }
        }
        if(r2.read()==0){
            wait(0.05);
            if(r2.read()==0){
            right1=0;
            right2=max;
            }
        }

        int count1=0;
        int old1=1;
        int now1=1;

        if(s1.read()==0){
            old1=now1;
            now1=s1.read();
            if(now1 == 0 && old1 == 1) {
                wait(0.05);
                now1 = s1.read();
                if(now1 == 0){
                    count1++;
                    }
            }
            if(count1 == 1){
                    servo1.pulsewidth_us(500);
                }else{
                    servo1.pulsewidth_us(2400);
                    count1=0;
                    }
         }

         int count2=0;
         int old2=1;
         int now2=1;

        if(s2.read()==0){
            old2=now2;
            now2=s2.read();
            if(now2 == 0 && old2 == 1) {
                wait(0.05);
                now2 = s2.read();
                if(now2 == 0){
                    count2++;
                    }
                }
                if(count2 == 1){
                        servo2.pulsewidth_us(500);
                    }else{
                        servo2.pulsewidth_us(2400);
                        count2=0;
                        }
                }

            printf("motor=%f,%f,%f,%f\r\n",left1.read(),left2.read(),right1.read(),right2.read());
        */
    }
}