a
Dependencies: MotorDriver_SU mbed
line8.cpp@0:ac03a5309047, 2014-11-28 (annotated)
- Committer:
- 12f2025e
- Date:
- Fri Nov 28 04:19:20 2014 +0000
- Revision:
- 0:ac03a5309047
a
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
12f2025e | 0:ac03a5309047 | 1 | #include "mbed.h" |
12f2025e | 0:ac03a5309047 | 2 | #include "MotorDriver_SU.h" |
12f2025e | 0:ac03a5309047 | 3 | |
12f2025e | 0:ac03a5309047 | 4 | DigitalIn sw(P0_1, PullUp); |
12f2025e | 0:ac03a5309047 | 5 | DigitalIn rightline(P0_12); |
12f2025e | 0:ac03a5309047 | 6 | DigitalIn leftline(P0_14); |
12f2025e | 0:ac03a5309047 | 7 | DigitalIn rightlift(P0_22); |
12f2025e | 0:ac03a5309047 | 8 | DigitalIn leftlift(P0_23); |
12f2025e | 0:ac03a5309047 | 9 | DigitalOut led1(P1_20); //left |
12f2025e | 0:ac03a5309047 | 10 | DigitalOut led2(P1_27); |
12f2025e | 0:ac03a5309047 | 11 | DigitalOut led3(P1_21); |
12f2025e | 0:ac03a5309047 | 12 | DigitalOut led4(P1_26); //right |
12f2025e | 0:ac03a5309047 | 13 | |
12f2025e | 0:ac03a5309047 | 14 | MotorDriver_SU motor(MOTOR_DOUBLE); |
12f2025e | 0:ac03a5309047 | 15 | MotorDriver_SU lift(MOTOR_SINGLE); |
12f2025e | 0:ac03a5309047 | 16 | |
12f2025e | 0:ac03a5309047 | 17 | int a = 0; |
12f2025e | 0:ac03a5309047 | 18 | int b = 0; |
12f2025e | 0:ac03a5309047 | 19 | int c = 0; |
12f2025e | 0:ac03a5309047 | 20 | |
12f2025e | 0:ac03a5309047 | 21 | int main(){ |
12f2025e | 0:ac03a5309047 | 22 | while(1){ |
12f2025e | 0:ac03a5309047 | 23 | while(sw == 0){ |
12f2025e | 0:ac03a5309047 | 24 | motor.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 25 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 26 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 27 | } |
12f2025e | 0:ac03a5309047 | 28 | while(sw == 1){ |
12f2025e | 0:ac03a5309047 | 29 | if((rightline == 0 && leftline == 1) && (rightlift == 1 && leftlift == 1)){ //WWBW |
12f2025e | 0:ac03a5309047 | 30 | motor.Drive(0, CW, 2200); |
12f2025e | 0:ac03a5309047 | 31 | motor.Drive(1, CW, 2200); |
12f2025e | 0:ac03a5309047 | 32 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 33 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 34 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 35 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 36 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 37 | } |
12f2025e | 0:ac03a5309047 | 38 | |
12f2025e | 0:ac03a5309047 | 39 | else if((rightline == 0 && leftline == 0) && (rightlift == 0 && leftlift == 0)){ //BBBB |
12f2025e | 0:ac03a5309047 | 40 | if(a == 0){ |
12f2025e | 0:ac03a5309047 | 41 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 42 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 43 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 44 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 45 | motor.Drive(0, CW, 2000); //0 = rightmotor, 1 = leftmotor |
12f2025e | 0:ac03a5309047 | 46 | motor.Drive(1, CW, 2000); |
12f2025e | 0:ac03a5309047 | 47 | lift.Drive(0, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 48 | wait(1.5); |
12f2025e | 0:ac03a5309047 | 49 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 50 | a = 1; |
12f2025e | 0:ac03a5309047 | 51 | } |
12f2025e | 0:ac03a5309047 | 52 | else{ |
12f2025e | 0:ac03a5309047 | 53 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 54 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 55 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 56 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 57 | motor.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 58 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 59 | lift.Drive(0, CW, 4095); |
12f2025e | 0:ac03a5309047 | 60 | wait(1.5); |
12f2025e | 0:ac03a5309047 | 61 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 62 | motor.Drive(0, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 63 | motor.Drive(1, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 64 | wait(1); |
12f2025e | 0:ac03a5309047 | 65 | } |
12f2025e | 0:ac03a5309047 | 66 | } |
12f2025e | 0:ac03a5309047 | 67 | else if((rightline == 0 && leftline == 0) && (rightlift == 1 && leftlift == 0)){ //BBBW |
12f2025e | 0:ac03a5309047 | 68 | if(c == 0){ |
12f2025e | 0:ac03a5309047 | 69 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 70 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 71 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 72 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 73 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 74 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 75 | wait(0.7); |
12f2025e | 0:ac03a5309047 | 76 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 77 | motor.Drive(1, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 78 | wait(0.1); |
12f2025e | 0:ac03a5309047 | 79 | c = 1; |
12f2025e | 0:ac03a5309047 | 80 | } |
12f2025e | 0:ac03a5309047 | 81 | else{ |
12f2025e | 0:ac03a5309047 | 82 | motor.Drive(0, CW, 2200); |
12f2025e | 0:ac03a5309047 | 83 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 84 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 85 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 86 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 87 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 88 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 89 | } |
12f2025e | 0:ac03a5309047 | 90 | } |
12f2025e | 0:ac03a5309047 | 91 | else if((rightline == 0 && leftline == 0) && (rightlift == 0 && leftlift == 1)){ //WBBB |
12f2025e | 0:ac03a5309047 | 92 | if(b == 0){ |
12f2025e | 0:ac03a5309047 | 93 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 94 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 95 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 96 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 97 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 98 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 99 | wait(1); |
12f2025e | 0:ac03a5309047 | 100 | motor.Drive(0, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 101 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 102 | wait(0.5); |
12f2025e | 0:ac03a5309047 | 103 | b = 1; |
12f2025e | 0:ac03a5309047 | 104 | } |
12f2025e | 0:ac03a5309047 | 105 | else{ |
12f2025e | 0:ac03a5309047 | 106 | motor.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 107 | motor.Drive(1, CW, 2200); |
12f2025e | 0:ac03a5309047 | 108 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 109 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 110 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 111 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 112 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 113 | } |
12f2025e | 0:ac03a5309047 | 114 | } |
12f2025e | 0:ac03a5309047 | 115 | else if((rightline == 0 && leftline == 0) && (rightlift == 1 && leftlift == 1)){ //WBBW * |
12f2025e | 0:ac03a5309047 | 116 | motor.Drive(0, CW, 2200); |
12f2025e | 0:ac03a5309047 | 117 | motor.Drive(1, CW, 1100); |
12f2025e | 0:ac03a5309047 | 118 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 119 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 120 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 121 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 122 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 123 | } |
12f2025e | 0:ac03a5309047 | 124 | |
12f2025e | 0:ac03a5309047 | 125 | else if((rightline == 1 && leftline == 1) && (rightlift == 1 && leftlift == 0)){ //BWWW * |
12f2025e | 0:ac03a5309047 | 126 | if(c == 0){ |
12f2025e | 0:ac03a5309047 | 127 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 128 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 129 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 130 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 131 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 132 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 133 | wait(0.7); |
12f2025e | 0:ac03a5309047 | 134 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 135 | motor.Drive(1, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 136 | wait(0.1); |
12f2025e | 0:ac03a5309047 | 137 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 138 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 139 | wait(0.3); |
12f2025e | 0:ac03a5309047 | 140 | c = 1; |
12f2025e | 0:ac03a5309047 | 141 | } |
12f2025e | 0:ac03a5309047 | 142 | else{ |
12f2025e | 0:ac03a5309047 | 143 | motor.Drive(0, CW, 1500); |
12f2025e | 0:ac03a5309047 | 144 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 145 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 146 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 147 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 148 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 149 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 150 | } |
12f2025e | 0:ac03a5309047 | 151 | } |
12f2025e | 0:ac03a5309047 | 152 | else if((rightline == 1 && leftline == 1) && (rightlift == 0 && leftlift == 1)){ //WWWB |
12f2025e | 0:ac03a5309047 | 153 | if(b == 0){ |
12f2025e | 0:ac03a5309047 | 154 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 155 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 156 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 157 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 158 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 159 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 160 | wait(1); |
12f2025e | 0:ac03a5309047 | 161 | motor.Drive(0, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 162 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 163 | wait(0.5); |
12f2025e | 0:ac03a5309047 | 164 | b = 1; |
12f2025e | 0:ac03a5309047 | 165 | } |
12f2025e | 0:ac03a5309047 | 166 | else{ |
12f2025e | 0:ac03a5309047 | 167 | motor.Drive(0, CW, 500); |
12f2025e | 0:ac03a5309047 | 168 | motor.Drive(1, CW, 1500); |
12f2025e | 0:ac03a5309047 | 169 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 170 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 171 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 172 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 173 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 174 | } |
12f2025e | 0:ac03a5309047 | 175 | } |
12f2025e | 0:ac03a5309047 | 176 | else if((rightline == 1 && leftline == 1) && (rightlift == 1 && leftlift == 1)){ //WWWW |
12f2025e | 0:ac03a5309047 | 177 | motor.Drive(0, CCW, 650); |
12f2025e | 0:ac03a5309047 | 178 | motor.Drive(1, CW, 1500); |
12f2025e | 0:ac03a5309047 | 179 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 180 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 181 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 182 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 183 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 184 | } |
12f2025e | 0:ac03a5309047 | 185 | |
12f2025e | 0:ac03a5309047 | 186 | else if((rightline == 0 && leftline == 1) && (rightlift == 0 && leftlift == 0)){ //BWBB |
12f2025e | 0:ac03a5309047 | 187 | if(a == 0){ |
12f2025e | 0:ac03a5309047 | 188 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 189 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 190 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 191 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 192 | motor.Drive(0, CW, 2000); |
12f2025e | 0:ac03a5309047 | 193 | motor.Drive(1, CW, 2000); |
12f2025e | 0:ac03a5309047 | 194 | lift.Drive(0, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 195 | wait(1.5); |
12f2025e | 0:ac03a5309047 | 196 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 197 | a = 1; |
12f2025e | 0:ac03a5309047 | 198 | } |
12f2025e | 0:ac03a5309047 | 199 | else{ |
12f2025e | 0:ac03a5309047 | 200 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 201 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 202 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 203 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 204 | motor.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 205 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 206 | lift.Drive(0, CW, 4095); |
12f2025e | 0:ac03a5309047 | 207 | wait(1.5); |
12f2025e | 0:ac03a5309047 | 208 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 209 | motor.Drive(0, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 210 | motor.Drive(1, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 211 | wait(1); |
12f2025e | 0:ac03a5309047 | 212 | } |
12f2025e | 0:ac03a5309047 | 213 | } |
12f2025e | 0:ac03a5309047 | 214 | else if((rightline == 0 && leftline == 1) && (rightlift == 1 && leftlift == 0)){ //BWBW |
12f2025e | 0:ac03a5309047 | 215 | if(c == 0){ |
12f2025e | 0:ac03a5309047 | 216 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 217 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 218 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 219 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 220 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 221 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 222 | wait(0.7); |
12f2025e | 0:ac03a5309047 | 223 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 224 | motor.Drive(1, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 225 | wait(0.1); |
12f2025e | 0:ac03a5309047 | 226 | c = 1; |
12f2025e | 0:ac03a5309047 | 227 | } |
12f2025e | 0:ac03a5309047 | 228 | else{ |
12f2025e | 0:ac03a5309047 | 229 | motor.Drive(0, CW, 2200); |
12f2025e | 0:ac03a5309047 | 230 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 231 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 232 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 233 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 234 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 235 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 236 | } |
12f2025e | 0:ac03a5309047 | 237 | } |
12f2025e | 0:ac03a5309047 | 238 | else if((rightline == 0 && leftline == 1) && (rightlift == 0 && leftlift == 1)){ //WWBB |
12f2025e | 0:ac03a5309047 | 239 | if(b == 0){ |
12f2025e | 0:ac03a5309047 | 240 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 241 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 242 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 243 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 244 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 245 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 246 | wait(1); |
12f2025e | 0:ac03a5309047 | 247 | motor.Drive(0, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 248 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 249 | wait(0.5); |
12f2025e | 0:ac03a5309047 | 250 | b = 1; |
12f2025e | 0:ac03a5309047 | 251 | } |
12f2025e | 0:ac03a5309047 | 252 | else{ |
12f2025e | 0:ac03a5309047 | 253 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 254 | motor.Drive(1, CW, 1500); |
12f2025e | 0:ac03a5309047 | 255 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 256 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 257 | led2 = 0; |
12f2025e | 0:ac03a5309047 | 258 | led3 = 1; |
12f2025e | 0:ac03a5309047 | 259 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 260 | } |
12f2025e | 0:ac03a5309047 | 261 | } |
12f2025e | 0:ac03a5309047 | 262 | |
12f2025e | 0:ac03a5309047 | 263 | else if((rightline == 1 && leftline == 0) && (rightlift == 0 && leftlift == 0)){ //BBWB |
12f2025e | 0:ac03a5309047 | 264 | if(a == 0){ |
12f2025e | 0:ac03a5309047 | 265 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 266 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 267 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 268 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 269 | motor.Drive(0, CW, 2000); |
12f2025e | 0:ac03a5309047 | 270 | motor.Drive(1, CW, 2000); |
12f2025e | 0:ac03a5309047 | 271 | lift.Drive(0, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 272 | wait(1.5); |
12f2025e | 0:ac03a5309047 | 273 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 274 | a = 1; |
12f2025e | 0:ac03a5309047 | 275 | } |
12f2025e | 0:ac03a5309047 | 276 | else{ |
12f2025e | 0:ac03a5309047 | 277 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 278 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 279 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 280 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 281 | motor.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 282 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 283 | lift.Drive(0, CW, 4095); |
12f2025e | 0:ac03a5309047 | 284 | wait(1.5); |
12f2025e | 0:ac03a5309047 | 285 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 286 | motor.Drive(0, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 287 | motor.Drive(1, CCW, 4095); |
12f2025e | 0:ac03a5309047 | 288 | wait(1); |
12f2025e | 0:ac03a5309047 | 289 | } |
12f2025e | 0:ac03a5309047 | 290 | } |
12f2025e | 0:ac03a5309047 | 291 | else if((rightline == 1 && leftline == 0) && (rightlift == 1 && leftlift == 0)){ //BBWW |
12f2025e | 0:ac03a5309047 | 292 | if(c == 0){ |
12f2025e | 0:ac03a5309047 | 293 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 294 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 295 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 296 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 297 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 298 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 299 | wait(0.7); |
12f2025e | 0:ac03a5309047 | 300 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 301 | motor.Drive(1, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 302 | wait(0.1); |
12f2025e | 0:ac03a5309047 | 303 | c = 1; |
12f2025e | 0:ac03a5309047 | 304 | } |
12f2025e | 0:ac03a5309047 | 305 | else{ |
12f2025e | 0:ac03a5309047 | 306 | motor.Drive(0, CW, 2200); |
12f2025e | 0:ac03a5309047 | 307 | motor.Drive(1, STOP, 0); |
12f2025e | 0:ac03a5309047 | 308 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 309 | led1 = 1; |
12f2025e | 0:ac03a5309047 | 310 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 311 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 312 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 313 | } |
12f2025e | 0:ac03a5309047 | 314 | } |
12f2025e | 0:ac03a5309047 | 315 | else if((rightline == 1 && leftline == 0) && (rightlift == 0 && leftlift == 1)){ //WBWB |
12f2025e | 0:ac03a5309047 | 316 | if(b == 0){ |
12f2025e | 0:ac03a5309047 | 317 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 318 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 319 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 320 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 321 | motor.Drive(0, CW, 1000); |
12f2025e | 0:ac03a5309047 | 322 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 323 | wait(1); |
12f2025e | 0:ac03a5309047 | 324 | motor.Drive(0, CCW, 1000); |
12f2025e | 0:ac03a5309047 | 325 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 326 | wait(0.5); |
12f2025e | 0:ac03a5309047 | 327 | b = 1; |
12f2025e | 0:ac03a5309047 | 328 | } |
12f2025e | 0:ac03a5309047 | 329 | else{ |
12f2025e | 0:ac03a5309047 | 330 | motor.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 331 | motor.Drive(1, CW, 2200); |
12f2025e | 0:ac03a5309047 | 332 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 333 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 334 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 335 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 336 | led4 = 1; |
12f2025e | 0:ac03a5309047 | 337 | } |
12f2025e | 0:ac03a5309047 | 338 | } |
12f2025e | 0:ac03a5309047 | 339 | else{ //WBWW |
12f2025e | 0:ac03a5309047 | 340 | motor.Drive(0, CW, 2200); |
12f2025e | 0:ac03a5309047 | 341 | motor.Drive(1, CW, 1000); |
12f2025e | 0:ac03a5309047 | 342 | lift.Drive(0, STOP, 0); |
12f2025e | 0:ac03a5309047 | 343 | led1 = 0; |
12f2025e | 0:ac03a5309047 | 344 | led2 = 1; |
12f2025e | 0:ac03a5309047 | 345 | led3 = 0; |
12f2025e | 0:ac03a5309047 | 346 | led4 = 0; |
12f2025e | 0:ac03a5309047 | 347 | } |
12f2025e | 0:ac03a5309047 | 348 | } |
12f2025e | 0:ac03a5309047 | 349 | } |
12f2025e | 0:ac03a5309047 | 350 | } |