4. Using the preloaded demo program
Your 3pi+ 32U4 ships preloaded with a program that demonstrates most of its features. We recommend trying out this program to familiarize yourself with what it can do before moving on to programming it yourself.
When you first turn on your 3pi, you should hear a beep and see an introductory screen followed by a prompt to press the B button, which will take you to the main menu. On the original (LCD) version of the 3pi+ 32U4, if you hear a beep but do not see anything on the LCD, you might need to adjust the contrast potentiometer on the control board near the top right corner of the LCD. Once you are at the main menu, you can press C or A to scroll forward or backward through the menu, and you can press B to make a selection or to exit one of the demos. These demos are accessible from the menu:
- Power: This demo displays the battery voltage in millivolts, which should be above 5000 (5.0 Volts) for a fully-charged set of rechargeable batteries or a fresh set of alkalines, and indicates whether USB power is present.
- LineSens: This demo shows the current readings of the five IR line sensors using a bar graph. Bigger bars mean lower reflectance (e.g. the sensor is over something dark). Placing a reflective object such as your finger under one of the sensors should cause the corresponding reading to drop visibly on the graph. This demo also displays “C🞶” or “C·” to indicate that button C has an effect on the IR emitters—the emitters are on by default, and pressing C will turn them off for as long as the button is held. In indoor lighting conditions away from bright incandescent or halogen lights, all of the sensors should return entirely black readings with the IR emitters off.
- BumpSens: This demo lets you try out the bump sensors along the front side of the robot. While the left sensor is pressed, the screen will display “L” and the yellow LED will be on. While the right sensor is pressed, the screen will display “R” and the red LED will be on. The buzzer will also beep each time a bump sensors is pressed, with a different tone for left and right. Note: this demo will only work if the bump sensor supports have been cut; assembled versions ship with them already cut, but you will need to cut them yourself as described in the assembly instructions (Section 3) if you got the kit version.
- Inertial: This demo lets you try out the robot’s inertial sensors. As you make the robot roll, pitch, or yaw in your hands, the top line of the screen will display which axis (±X, Y, or Z) the robot is rotating about, as measured by the integrated three-axis gyro. While the robot is stationary, it should just display “Rot”, with no axis listed. The bottom line of the screen will display which robot axis is currently pointing up (i.e., in the opposite direction of gravity), as measured by the integrated three-axis accelerometer. When sitting on a flat table, it should say “Up+Z”. You can try tilting various parts of the robot to face up to see how that changes.
- Compass: This demo uses the robot’s integrated three-axis magnetometer to measure the Earth’s magnetic field and determine which compass direction it is facing. The demo is constantly calibrating, and in order to work well, the robot should initially be rotated about various axes (the screen will start by displaying “Turn me!” to indicate this). Please note that the Earth’s magnetic field can be distorted by stronger local magnetic fields, especially in close proximity to iron or steel, so if the demo is not working well, try changing locations. Also, please note that magnetic field orientations vary across the surface of the Earth, and magnetic north often deviates from true north.
- Motors: This demo lets you try out making the motors spin. Hold down A or C to run the motor on the corresponding side, or hold down both buttons to run both motors simultaneously. The motors will gradually ramp up to speed; in your own programs, you can switch them on much more abruptly. Tap A or C to flip the rotation direction of the corresponding motor (the arrows next to the button letters on the display indicate which direction the motors will turn).
- Encoders: This demo displays the left and right motor encoder counts on the screen. You can rotate the wheels by hand to see the counts increase or decrease (based on the direction of rotation). You can also use the A and C buttons to activate the motors rather than turning them by hand (they function the same way as they do in the motors demo described above).
- Spin: This demo makes the 3pi spin in place in both directions. Set it on the ground, press the B button to initiate the demo, and then step back and watch it spin!
- LEDs: This demo cycles through lighting the red, green, and yellow user LEDs.
- OLED or LCD: This demo shows you various text characters you can display on the OLED or LCD screen. Use the buttons to scroll through the pages of characters.
- Music: Plays an adaptation of J. S. Bach’s Fugue in D Minor for microcontroller and buzzer, while scrolling a text display. This demonstrates the ability of the 3pi+ to play music in the background.
- About (original LCD version only): This displays basic information about the 3pi+ on the LCD.
The source code for the demo program is included as part of the Pololu3piPlus32U4 Arduino Library (DemoForLCDVersion and DemoForOLEDVersion for the respective display types). See Section 7 for more information.