forked from jfriedly/robot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_encdr.ic
35 lines (29 loc) · 861 Bytes
/
test_encdr.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
#use "defines.ic"
int main() {
int disp_l, disp_r;
int motors = 0;
disp_l = disp_r = -1;
SHAFT_LEFT_COUNT = SHAFT_RIGHT_COUNT = 0;
init_shaft_encoders();
for(;;) {
if(stop_button())
SHAFT_LEFT_COUNT = SHAFT_RIGHT_COUNT = 0;
if(start_button()) {
while(start_button())
;
motors = !motors;
if(motors) {
motor(MOTOR_LEFT, 100);
motor(MOTOR_RIGHT, 100);
} else {
motor(MOTOR_LEFT, 0);
motor(MOTOR_RIGHT, 0);
}
}
if(SHAFT_LEFT_COUNT != disp_l || SHAFT_RIGHT_COUNT != disp_r) {
disp_l = SHAFT_LEFT_COUNT;
disp_r = SHAFT_RIGHT_COUNT;
printf("L:%d R:%d\n", disp_l, disp_r);
}
}
}