o

Dependencies:   MotorDriver_SU mbed

Committer:
12F2045K
Date:
Thu Nov 27 04:22:11 2014 +0000
Revision:
0:57da1a182e99
o

Who changed what in which revision?

UserRevisionLine numberNew contents of line
12F2045K 0:57da1a182e99 1 #include "mbed.h"
12F2045K 0:57da1a182e99 2 #include "MotorDriver_SU.h"
12F2045K 0:57da1a182e99 3 DigitalIn sw(P0_1,PullUp);
12F2045K 0:57da1a182e99 4 AnalogIn sensorleft(P0_23),sensorcenter(P0_14),sensorright(P0_12),sensorlift1(P0_22),sensorlift2(P0_21);
12F2045K 0:57da1a182e99 5 MotorDriver_SU motor(MOTOR_DOUBLE);
12F2045K 0:57da1a182e99 6 MotorDriver_SU lift(MOTOR_SINGLE);
12F2045K 0:57da1a182e99 7 int main() {
12F2045K 0:57da1a182e99 8 float hoge,pool,fink,coen,ronin;
12F2045K 0:57da1a182e99 9 while(sw == 1){
12F2045K 0:57da1a182e99 10 ;
12F2045K 0:57da1a182e99 11 }
12F2045K 0:57da1a182e99 12 wait(0.1);
12F2045K 0:57da1a182e99 13 while(sw == 0){
12F2045K 0:57da1a182e99 14 ;
12F2045K 0:57da1a182e99 15 }
12F2045K 0:57da1a182e99 16 while(1){
12F2045K 0:57da1a182e99 17 hoge = sensorleft.read();
12F2045K 0:57da1a182e99 18 pool = sensorcenter.read();
12F2045K 0:57da1a182e99 19 fink = sensorright.read();
12F2045K 0:57da1a182e99 20 coen = sensorlift1.read();
12F2045K 0:57da1a182e99 21 ronin = sensorlift2.read();
12F2045K 0:57da1a182e99 22 if(coen < 0.7 && ronin < 0.7){
12F2045K 0:57da1a182e99 23 motor.Drive(0,STOP,0);
12F2045K 0:57da1a182e99 24 motor.Drive(1,STOP,0);
12F2045K 0:57da1a182e99 25 lift.Drive(0,CW,3000);
12F2045K 0:57da1a182e99 26 wait(1.5);
12F2045K 0:57da1a182e99 27 while(1){
12F2045K 0:57da1a182e99 28 lift.Drive(0,STOP,0);
12F2045K 0:57da1a182e99 29 motor.Drive(0,CW,1200);
12F2045K 0:57da1a182e99 30 motor.Drive(1,CW,1200);
12F2045K 0:57da1a182e99 31 wait(0.3);
12F2045K 0:57da1a182e99 32 while(1){
12F2045K 0:57da1a182e99 33 hoge = sensorleft.read();
12F2045K 0:57da1a182e99 34 pool = sensorcenter.read();
12F2045K 0:57da1a182e99 35 fink = sensorright.read();
12F2045K 0:57da1a182e99 36 coen = sensorlift1.read();
12F2045K 0:57da1a182e99 37 ronin = sensorlift2.read();
12F2045K 0:57da1a182e99 38 if(coen < 0.7 && ronin < 0.7){
12F2045K 0:57da1a182e99 39 motor.Drive(0,STOP,0);
12F2045K 0:57da1a182e99 40 motor.Drive(1,STOP,0);
12F2045K 0:57da1a182e99 41 lift.Drive(0,CCW,3000);
12F2045K 0:57da1a182e99 42 wait(1.5);
12F2045K 0:57da1a182e99 43 while(1){
12F2045K 0:57da1a182e99 44 lift.Drive(0,STOP,0);
12F2045K 0:57da1a182e99 45 motor.Drive(0,CCW,1500);
12F2045K 0:57da1a182e99 46 motor.Drive(1,CCW,1500);
12F2045K 0:57da1a182e99 47 }
12F2045K 0:57da1a182e99 48 }
12F2045K 0:57da1a182e99 49 else if(fink < 0.7){
12F2045K 0:57da1a182e99 50 motor.Drive(0,CW,0);
12F2045K 0:57da1a182e99 51 motor.Drive(1,CW,1100);
12F2045K 0:57da1a182e99 52 }
12F2045K 0:57da1a182e99 53 else if(hoge < 0.7){
12F2045K 0:57da1a182e99 54 motor.Drive(0,CW,1100);
12F2045K 0:57da1a182e99 55 motor.Drive(1,CW,0);
12F2045K 0:57da1a182e99 56 }
12F2045K 0:57da1a182e99 57 else if(pool < 0.7){
12F2045K 0:57da1a182e99 58 motor.Drive(0,CW,1150);
12F2045K 0:57da1a182e99 59 motor.Drive(1,CW,1200);
12F2045K 0:57da1a182e99 60 }
12F2045K 0:57da1a182e99 61 else{
12F2045K 0:57da1a182e99 62 lift.Drive(0,STOP,0);
12F2045K 0:57da1a182e99 63 }
12F2045K 0:57da1a182e99 64 }
12F2045K 0:57da1a182e99 65 }
12F2045K 0:57da1a182e99 66 }
12F2045K 0:57da1a182e99 67 else if(fink < 0.7){
12F2045K 0:57da1a182e99 68 motor.Drive(0,CW,0);
12F2045K 0:57da1a182e99 69 motor.Drive(1,CW,850);
12F2045K 0:57da1a182e99 70 }
12F2045K 0:57da1a182e99 71 else if(hoge < 0.7){
12F2045K 0:57da1a182e99 72 motor.Drive(0,CW,850);
12F2045K 0:57da1a182e99 73 motor.Drive(1,CW,0);
12F2045K 0:57da1a182e99 74 }
12F2045K 0:57da1a182e99 75 else if(pool < 0.7){
12F2045K 0:57da1a182e99 76 motor.Drive(0,CW,850);
12F2045K 0:57da1a182e99 77 motor.Drive(1,CW,850);
12F2045K 0:57da1a182e99 78 }
12F2045K 0:57da1a182e99 79 else{
12F2045K 0:57da1a182e99 80 lift.Drive(0,STOP,0);
12F2045K 0:57da1a182e99 81
12F2045K 0:57da1a182e99 82 }
12F2045K 0:57da1a182e99 83 }
12F2045K 0:57da1a182e99 84 }