4. Using the preloaded example programs

The Zumo 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 Zumo:

  1. Install four charged AA batteries and slide the power switch to the “On” position. 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 Zumo 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 that 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. 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_opponent.py Uses the proximity sensors to locate an opponent robot or any other reflective object and turns to face it.
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.
i2c0_scan.py Shows devices detected on I2C bus 0, using pins GP4 and GP5. This will include the on-board IMU sensors and devices you have connected to the expansion ports.
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 line sensors, displaying the results as a bar graph. You can press A to calibrate, the robot will 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.
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.
proximity_demo.py Displays proximity sensor readings as a bar graph.
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.

You can learn more about these example programs by reading their source code.

Related Products

Zumo 2040 Robot Kit (No Motors)
Zumo 2040 Robot (Assembled with 50:1 HP Motors)
Zumo 2040 Robot (Assembled with 75:1 HP Motors)
Zumo 2040 Robot (Assembled with 100:1 HP Motors)
Zumo 2040 Main Board
Zumo 2040 Front Sensor Array
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