-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_motors.ic
62 lines (55 loc) · 1.51 KB
/
test_motors.ic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#use "util.ic"
#define MOT_FORWARD 0
#define MOT_CW 1
#define MOT_CCW 2
#define MOT_BACKWARD 3
#define MOTOR_LEFT 3
#define MOTOR_RIGHT 1
#define MOTOR_POWER 100
int main() {
int sel = 0, old = -1;
ao();
for(;;) {
while(!start_button()) {
sel = knob() / 64;
if(sel != old) {
switch(sel) {
case MOT_FORWARD:
printf("Forward\n");
break;
case MOT_CW:
printf("Pivot clockwise\n");
break;
case MOT_CCW:
printf("Pivot ctrclkwise\n");
break;
case MOT_BACKWARD:
printf("Backward\n");
break;
}
old = sel;
}
}
switch(sel) {
case MOT_FORWARD:
motor(MOTOR_LEFT, MOTOR_POWER);
motor(MOTOR_RIGHT, MOTOR_POWER);
break;
case MOT_CW:
motor(MOTOR_LEFT, -MOTOR_POWER);
motor(MOTOR_RIGHT, MOTOR_POWER);
break;
case MOT_CCW:
motor(MOTOR_LEFT, MOTOR_POWER);
motor(MOTOR_RIGHT, -MOTOR_POWER);
break;
case MOT_BACKWARD:
motor(MOTOR_LEFT, -MOTOR_POWER);
motor(MOTOR_RIGHT, -MOTOR_POWER);
break;
}
while(!stop_button())
;
ao();
}
}