6. Programming Your 3pi

6.a. Downloading and Installing the C/C++ Library
6.b. Compiling a Simple Program

To do more with your 3pi than explore the demo program or use it as a serial slave to a master device, you will need to program it, which requires a computer and an external AVR ISP programmer like our USB AVR programmer.

You will also need software that can compile your programs and transfer them to your 3pi via your programmer. For Windows users, we recommend getting the necessary software by downloading and installing the Pololu AVR Development Bundle (~200MB exe), which contains:

  1. WinAVR, a free, open-source suite of development tools for the AVR family of microcontrollers, including the GNU GCC compiler for C/C++.
  2. AVR Studio, Atmel’s free integrated development environment (IDE) that natively works with WinAVR’s free GCC C/C++ compiler. AVR Studio includes AVR ISP software that will let you upload your programs to the 3pi.
  3. The Pololu AVR C/C++ Library, which makes it easy to use the advanced features of your 3pi.
  4. The drivers and software for the Pololu USB AVR Programmer.

If you are using the Pololu USB AVR Programmer, the development bundle should be enough to get you started, though we still recommend you take a moment to look through the programmer user’s guide and get more familiar with it and its bonus features. If you are using a different programmer, you will need to set up your programmer by following its installation instructions.

Note: The rest of this guide will assume you are programming the 3pi using AVR Studio 4 in Windows, but it is possible to program the 3pi on other platforms. For more general instructions on AVR programming, including Linux and Mac OS X installation instructions, see the Pololu USB AVR Programmer User’s Guide and the Pololu AVR C/C++ Library User’s Guide. We provide limited support for 3pi programming on the Mac. You can also program your 3pi using the Arduino IDE and an external ICSP programmer, such as our USB AVR Programmer. For instructions on this approach, please see our guide: Programming Orangutans and the 3pi Robot from the Arduino Environment.

Warning: Do not attempt to program your 3pi if its batteries are drained or uncharged (make sure you charge any new rechargeable batteries fully before you first use them). Losing power during programming could permanently disable your 3pi.