187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
slave_print(
"OK"
);
// play a tune
char
tune[] =
"\xB3 l16o6gab>c"
;
tune[1] =
sizeof
(tune)-3;
serial_send_blocking(tune,
sizeof
(tune)-1);
// wait
wait_for_button(ALL_BUTTONS);
// reset calibration
slave_reset_calibration();
time_reset();
slave_auto_calibrate();
unsigned
char
speed1 = 0, speed2 = 0;
// read sensors in a loop
while
(1)
{
serial_send(
"\x87"
,1);
// returns calibrated sensor values
// read 10 characters
if
(serial_receive_blocking(buffer, 10, 100))
break
;
// get the line position
serial_send(
"\xB6"
, 1);
int
line_position[1];
if
(serial_receive_blocking((
char
*)line_position, 2, 100))
break
;
// get the battery voltage
serial_send(
"\xB1"
,1);
// read 2 bytes
int
battery_millivolts[1];
if
(serial_receive_blocking((
char
*)battery_millivolts, 2, 100))
break
;
// display readings
display_levels((unsigned
int
*)buffer);
lcd_goto_xy(5,0);
line_position[0] /= 4;
// to get it into the range of 0-1000
if
(line_position[0] == 1000)
line_position[0] = 999;
// keep to a max of 3 chars
print_long(line_position[0]);
print(
"
"
);
lcd_goto_xy(0,1);
print_long(battery_millivolts[0]);
print(
" mV
"
);
delay_ms(10);
// if button A is pressed, increase motor1 speed
if
(button_is_pressed(BUTTON_A) && speed1 < 127)
+;
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
10. Expansion Information
Page 81 of 85
Содержание 0J5840
Страница 24: ...Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 5 How Your 3pi Works Page 24 of 85...
Страница 67: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 67 of 85...
Страница 77: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 77 of 85...