16-299: Getting started with the Elegoo Balancing Robot Lab (rp2040 version)


Before we start, I want to point out that there are two connectors for the USB A to micro USB cable that connects the robot to your computer. One is for connecting to the Arduino Nano RP2040 Connect computer, and one is for recharging the battery:

The Arduino USB connectors are fragile, and can easily be broken off the board. Please be gentle inserting and removing the USB cable. If you want to be really safe, never unplug the USB cable at the Arduino and use a second USB cable to charge the battery.


Setting up the Arduino Integrated Development Environment (IDE).

1) I assume you have some sort of computer (PC: Mac, Windows, or Linux).

2) Please charge the battery on the robot fully. This makes the battery happier.

3) We need to get the programming environment (Integrated Development Environment (IDE)) from Arduino, which runs on your computer. Download the latest version of the Arduino IDE (2.3.7 as of Jan 1, 2026) onto your computer. The menu next to the DOWNLOAD button lets you select Windows, Linux, or Mac versions, and variants on how to install it.

4) Helpful info is available. Googling "how to use Arduino" or searching for it on Youtube will get you many tutorials and helpful videos.

5) Trying running the Arduino IDE (Type arduino to a command line in Linux, or just click on the Arduino icon in all OSes). The goal is to get the window below on your screeen. Then exit the program.

6) We are using the Nano RP2040 Connect Arduino board which is not the default in the IDE. We need to load information about that type of board (called a "board manager" in the Arduino IDE) once from the board library. We use the board manager described here. Follow these instructions. Note that the instructions are slightly out of date. The name of the board manager is now "Raspberry Pi Pico/RP240/RP2350 ..." and you press "INSTALL" rather than "Add"



7) Connect your computer to the Nano RP2040 Connect with the USB cable that comes with your robot. When you connect the RP2040 Connect with USB to your computer, it gets power and various LEDs light up. There is a green LED that indicates the RP2040 is getting power. The default program in the RP2040 blinks LEDs. The traditional one color LED (orange) should be blinking at 1Hz (but maybe not since that LED pin is also used for a motor encoder). The fancy new multicolor LED should definitely be changing colors.

8) Start the Arduino IDE again. The Arduino IDE may figure out you are using an RP2040 and show "Arduino Nano RP204..." in the menu box in the green stripe.

If that box is saying "Select Board" you will need to select a board. Click on the drop down menu, and you should see "Arduino Nano RP2040 Co..." and a port listed. Click on that.

Whenever asked, or if you manually need to open the Boards Manager (click on the board icon on the left or "Tools->Boards->Boards Manager") always choose "Raspberry Pi Pico/RP240/RP2350 ...". I got version 5.4.4 on January 1, 2026.

9) You can check the right things are happening by clicking on "Tools->Board" and "Tools->Port" and matching the windows below (you may have to select the specific port). Sometimes the Arduino IDE gets confused about ports. Unplugging and plugging in the USB cable (at the laptop connector) sometimes fixes that. Otherwise, check out the Tools menu and look at the Port entry. "DFU" and "dfu" are bad selections, on linux look for something starting with /dev/tty.



I got the following message when I did a (.zip) installation on a Linux box:

[5001:0101/185001.787776:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /home/cga/software/arduino-ide_2.3.7_Linux_64bit/chrome-sandbox is owned by root and has mode 4755.
Trace/breakpoint trap (core dumped)

Here is what I did:

$ sudo chown root /home/cga/software/arduino-ide_2.3.7_Linux_64bit/chrome-sandbox
$ sudo chgrp root /home/cga/software/arduino-ide_2.3.7_Linux_64bit/chrome-sandbox
$ sudo chmod 4775 /home/cga/software/arduino-ide_2.3.7_Linux_64bit/chrome-sandbox



Getting some software to test

Download 16299-26-1.zip and put the contents in your top level Arduino directory. This results in (on linux):

~/Arduino$ ls
libraries  test_motor           test_picoencoder  test_voltage
test_imu   test_multicolor_led  test_servo
The library directory/folder includes
~/Arduino$ ls libraries
Arduino_LSM6DSOX-cga  PicoEncoder  PicoEncoder-cga  WiFiNINA
These libraries are needed to run the test_xxx programs. -cga indicates my version of a librariy. Arduino_LSM6DSOX-cga is a library for the Inertial Measurement Unit (IMU, which includes an accelerometer and a gyro). PicoEncoder-cga is a library for reading optical encoders (which measure wheel angle). WiFiNINA makes some special RP2040 functions available.

To run these programs, click on File, Open, navigate to the folder the programs are in, and then click on the program name to load it into a new instance of the arduino window. Click the right arrow in the green stripe to compile and download it to an Nano RP2040 connected with a USB cable. For programs with serial output, start a serial monitor (tools menu) at 2000000 baud to see the output. Any numbers at the end of the program names are version numbers.

test_multicolor_led: Most basic test. Cycle the multicolor LED through red, green, and blue continuously. The sequence is different from the program that comes pre-loaded in the RP2040, so if you see colors other than red, green, or blue (like yellow or the LED is not on) this program is not running. No serial output. Can be run even when the Arduino RP2040 is not installed on the robot controller board.

test_voltage: Reads the battery voltage (USB-provided voltage if no battery is attached). Serial output. Can be run even when the Arduino RP2040 is not installed on the robot controller board.

test_imu: Read the IMU. Serial output. Can be run even when the Arduino RP2040 is not installed on the robot controller board.

test_picoencoder: Test the PicoEncoder library reading the encoders. RP2040 needs to installed in robot. Serial output.

Programs that run the motors (test_motor, and test_servo below, for example) need to have the battery charged and turned on to work well. Some USB ports on some laptops can handle the additional current and wimpily move the motors, but some cannot.

test_motor: Test driving the motors (need the battery attached and on and the wheels off the ground, which is easily achieved by putting the robot upside down). RP2040 needs to installed in robot. Serial output. Serial input: for safety you need to type the letter 'g' to run the motor, and the program is set up to stop driving the motor relatively quickly. You can change that by editing the program.

test_servo: Use the encoders and the motors to implement a simple servo on one of the wheels (need the battery attached and on and the wheels off the ground, which is easily achieved by putting the robot upside down). RP2040 needs to installed in robot. Serial output. Serial input: for safety you need to type the letter 'g' to run the motor, and the program is set up to stop driving the motor relatively quickly. You can change that by editing the program.