10.c. Available I/O on the 3pi's ATmegaxx8
The easiest way to expand your 3pi’s capabilities is probably to turn your 3pi into a “smart base” that
is controlled by the microcontroller of your choosing, as described in
. This allows you to
connect your additional electronics to your secondary microcontroller and only requires you to make
connections to pins PD0 and PD1 on the 3pi. These two pins are completely unused digital I/O lines
that connect to the ATmegaxx8’s UART module when that module is enabled. You can freely use PD0
and PD1 for general-purpose digital I/O, or you can use them for serial communication with another
microcontroller, a serially-controlled device, or a computer (note that you will need to convert the signal
to RS-232 levels or USB to communicate with a computer).
In addition to PD0 and PD1, the 3pi robot has a limited number of I/O lines that can be used as inputs
for additional sensors or to control additional electronics such as LEDs or servos. These I/O lines can
be accessed through the pads at the center of the 3pi, between the two motors, labeled PD0, PD1,
ADC6, ADC7, and PC5. If you are using an expansion kit, these lines are brought up to the expansion
PCB.
Pins PC5, ADC6, and ADC7 are all connected to 3pi hardware via removable shorting blocks. By
removing the shorting block, you can use these pins for your own electronics. Pin PC5 can be used
as either a digital I/O or an analog input. When its shorting block is in place, it controls the emitters
for the IR sensors; when its shorting block is removed, the emitters are always on. Pin ADC6 is a
dedicated analog input that connects to a voltage divider circuit that monitors the battery voltage when
its shorting block is in place, and pin ADC7 is a dedicated analog input that connects to the user
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
else if
(speed1 > 1)
speed1 -= 2;
else if
(speed1 > 0)
speed1 = 0;
// if button C is pressed, control motor2
if
(button_is_pressed(BUTTON_C) && speed2 < 127)
+;
else if
(speed2 > 1)
speed2 -= 2;
else if
(speed2 > 0)
speed2 = 0;
// if button B is pressed, do PID control
if
(button_is_pressed(BUTTON_B))
slave_set_pid(40, 1, 20, 3, 2);
else
{
slave_stop_pid();
slave_set_motors(speed1, speed2);
}
}
}
while
(1);
}
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
10. Expansion Information
Page 82 of 85