4. Using the preloaded example programs

The 3pi+ 2040 Robot ships with a set of pre-installed programs that demonstrate all of its features. You can try them out without installing any software, and later you can refer to them as programming examples (see Section 5). To get started, just power up the robot. There are two alternative ways to power the 3pi+:

  1. Install four charged AAA batteries and press the power button. The top blue LED next to the power button will illuminate, and the robot will turn on.
  2. Connect the robot to USB. The green LED next to the reset button will illuminate, and the robot will turn on automatically.

Note that if you are not using battery power, the motors will not run.

On startup, the 3pi+ will show this splash screen on its OLED display:

After a few seconds it will switch to the menu of example programs, or you can press button C to proceed to the menu immediately. (On this screen you can also press A to exit the program or B for bootloader mode.)

The menu shows a list of all the Python files installed at the top level of the MicroPython drive. As you can see above, it also tries to show the battery voltage for convenience. With batteries installed and the power circuit on, it should generally show a value of 4.8 V or higher. If batteries are not installed or the power circuit is off, this number will be some low value that doesn’t mean anything.

Navigate up and down the menu with buttons A and C, respectively, and press button B to run the selected file. When you are done with the one program, you can press the reset button to restart and return to the menu.

Here is a list of the pre-installed programs:

File Description
blink.py Blinks the yellow LED on and off.
button_test.py Lets you type letters with the three pushbuttons and the two bump sensors. Demonstrates debouncing by using a very slow setting for A: if you tap A twice quickly only the first press will be registered.
encoder_test.py You can gently rotate the wheels by hand to see the wheel encoders measure rotation. For additional feedback, the yellow LED also toggles with each encoder tick.
error.py Simply raises a Python exception. This shows how the built-in menu system helps debugging by emitting a sound and displaying the error on the screen.
face_uphill.py Detects slanted surfaces and turns the robot to face uphill.
gyro_turn.py Press A or C to make the robot turn 90° using the gyroscope.
imu_test.py Continuously reads the on-board accelerometer, gyro, and compass and displays all 9 values to the screen. The values are also available with more resolution on the serial terminal.
ir_sensor_demo.py Continuously reads the bump sensors and line sensors, displaying the results as a bar graph. You can press A to calibrate: the robot will immediately calibrate its bump sensors (which should not be pressed) then start continuously taking calibration readings from its line sensors. Slide the robot across a line, then press A when you are done calibrating. After calibration, press C to switch to calibrated reads for the line sensors. The bars for the bump sensors show as outlines when not pressed, and once calibrated they will be solid when detecting a press.
line_follower.py A PID line follower designed to follow a black line on a white surface. Follow the on-screen instructions to calibrate and start it running. Note that it is intentionally not very well tuned; this is intended as a starting point that you can improve.
motor_test.py Lets you run the left and right motors using buttons A and C. Hold a button to run the motor or tap it to change direction.
music.py Plays a song on the buzzer while blinking the LEDs and displaying the beats and measure numbers.
rgb_demo.py Demonstrates smoothly-changing rainbow effects on the RGB LEDs.
rotation_resist.py Spins the robot to counteract rotation detected by the gyro. Do not move the while robot while it says “Calibrating…” on the display.
self_test.py Tests basic functionality of the robot. You can also access this by holding A during startup.
siren.py Demonstrates sound and light effects.
spin.py Runs one motor forward and the other backward to spin the robot in place. Please disconnect your robot from USB for this one, and guard it to prevent it slipping off of a table or otherwise causing damage.
sys_info.py Shows CPU information, the flash serial ID, MicroPython firmware version, and disk/RAM usage.
wall_bumper.py Drives the robot forward until a collision is detected with the bump sensors, then backs up, turns, and continues.

Related Products

3pi+ 2040 Robot - Standard Edition (30:1 MP Motors), Assembled
3pi+ 2040 Robot - Turtle Edition (75:1 LP Motors), Assembled
3pi+ 2040 Robot - Hyper Edition (15:1 HPCB Motors), Assembled
3pi+ 2040 Robot Kit with 30:1 MP Motors (Standard Edition Kit)
3pi+ 2040 Robot Kit with 75:1 LP Motors (Turtle Edition Kit)
3pi+ 2040 Robot Kit with 15:1 HPCB Motors (Hyper Edition Kit)
3pi+ 2040 Control Board
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors