o

Dependencies:   MotorDriver_SU mbed

liftver2.0.cpp

Committer:
12F2045K
Date:
2014-11-27
Revision:
0:57da1a182e99

File content as of revision 0:57da1a182e99:

#include "mbed.h"
#include "MotorDriver_SU.h"
DigitalIn sw(P0_1,PullUp);
AnalogIn sensorleft(P0_23),sensorcenter(P0_14),sensorright(P0_12),sensorlift1(P0_22),sensorlift2(P0_21);
MotorDriver_SU motor(MOTOR_DOUBLE);
MotorDriver_SU lift(MOTOR_SINGLE);
int main() {
    float hoge,pool,fink,coen,ronin;
    while(sw == 1){
        ;
        }
        wait(0.1);
        while(sw == 0){
            ;
            }
    while(1){
        hoge = sensorleft.read();
        pool = sensorcenter.read();
        fink = sensorright.read();
        coen = sensorlift1.read();
        ronin = sensorlift2.read();
    if(coen < 0.7 && ronin < 0.7){
        motor.Drive(0,STOP,0);
        motor.Drive(1,STOP,0);
        lift.Drive(0,CW,3000);
        wait(1.5);
        while(1){
            lift.Drive(0,STOP,0);
            motor.Drive(0,CW,1200);
            motor.Drive(1,CW,1200);
            wait(0.3);
        while(1){
        hoge = sensorleft.read();
        pool = sensorcenter.read();
        fink = sensorright.read();
        coen = sensorlift1.read();
        ronin = sensorlift2.read();
        if(coen < 0.7 && ronin < 0.7){
            motor.Drive(0,STOP,0);
            motor.Drive(1,STOP,0);
            lift.Drive(0,CCW,3000);
            wait(1.5);
            while(1){
            lift.Drive(0,STOP,0);
            motor.Drive(0,CCW,1500);
            motor.Drive(1,CCW,1500);
            }
        }
        else if(fink < 0.7){
                motor.Drive(0,CW,0);
                motor.Drive(1,CW,1100);
        }
        else if(hoge < 0.7){
                motor.Drive(0,CW,1100);
                motor.Drive(1,CW,0);
        }
        else if(pool < 0.7){
                motor.Drive(0,CW,1150);
                motor.Drive(1,CW,1200);
        }
        else{
                lift.Drive(0,STOP,0);
        }
    }
    }
    }
    else if(fink < 0.7){
            motor.Drive(0,CW,0);
            motor.Drive(1,CW,850);
        }
    else if(hoge < 0.7){
            motor.Drive(0,CW,850);
            motor.Drive(1,CW,0);
    }
    else if(pool < 0.7){
            motor.Drive(0,CW,850);
            motor.Drive(1,CW,850);
    }
    else{
        lift.Drive(0,STOP,0);
          
    }
}
}