Configuring Arduino for 3pi

I was puzzled by instructions on this site on how to configure Arduino to work with the 3pi Robot:

because in Mac OS X there is no such directory (adjusting the version number to 23, which is current). It turns out that you need to find the Arduino Sketchbook location (specified in Preferences), which, in my case, is a directory called Arduino in the Documents directory. Inside Arduino you should create a directory called hardware, then a directory called 3pi (or Orangutan — the name is not important as long as you don’t call it Arduino). That’s where you add the boards.txt file with the three Orangutan settings.


We don’t do a lot with Macs here, and were unaware that the file structure was different. Thanks for sharing what you found out!

- Ben

Thanks, Ben,

I cannot get Arduino to compile a sketch for the 3pi.

I’ve tried with Arduino 1.0, Arduino 0023 and Arduino 0021 (since it’s used in the documentation on this website).

For example, here are the error messages I see when I try to compile the Polulu LED example:

OrangutanLEDExample.cpp:16:21: error: Arduino.h: No such file or directory
OrangutanLEDExample.cpp: In function 'void loop()':
OrangutanLEDExample.pde:-1: error: 'delay' was not declared in this scope

I have followed the procedures described in the document Programming Orangutans and the 3pi Robot from the Arduino Environment. I have added boards.txt and programmers.txt files to a 3pi directory in a hardware directory in the Arduino program area. The three Polulu boards show up fine in the Tools->Board menu.

From the error messages, it appears that the Arduino application cannot find the core header, even though the last line of boards.text reads

FWIW, I’m on a Mac running the current version of Max OS X Lion. The Arduino application works fine for regular Arduino programs, but won’t compile if I switch the board to an Orangutan/3pi.

You don’t need a 3pi folder in the hardware folder. You want to change the boards.txt and programmers.txt in the “arduino-1.0\hardware\arduino” folder. Since you created a new folder, the program tried to find the Arduino core there, instead of in the Arduino folder where it is.

If it wasn’t so late at night (3:24 AM EST), I’m sure I could have said the same thing and used the work “folder” less. My apologies.

Thanks for the advice, Dave, but it didn’t fix the problem.

The arduino website suggests:

Which is why I called the sub-directory 3pi.

If I take the files out of the 3pi directory and move them into the hardware directory, the three Polulu boards disappear from the Tools->Board menu. If I restore them to the 3pi directory, they spring back to life. So I think this is the correct way to handle the Polulu boards.

Problem is, the arduino application is treating them like strangers, looking for a new set of core files.

The Arduino Google Code developers website tells us:

In this case, since the Polulu boards are Arduino-compatible, I shouldn’t need a separate set of core files. That’s what I thought the line

was for in the boards.text file.

I know that everyone except me is working in Windows, which may be set up differently, though the documentation I’m quoting is not platform-specific.

Again, thanks for trying to help and I’m sorry my response is so long. Are you successfully compiling Orangutan applications using arduino?

Hello, petej.

Your latest post basically matches my understanding of how Arduino handles platforms. If you want the Orangutans to be treated as members of the “arduino” platform, you need to add them to the existing boards.txt that is part of the Arduino distribution inside hardware/arduino (and similarly edit the existing programmers.txt). I do not have experience with Macs, but from a quick Google search, it sounds like you can find those files by Ctrl-clicking the file that you downloaded/installed and selecting “Show Package Contents”, then navigating to Contents/Resources/Java/hardware/arduino. Does that help?

I think Arduino 1.0 changed a few things, so I’m not sure our Orangutan examples will work with it, but they should work fine for 0021 and 0023.

- Kevin

Thanks, Kevin. You just gave me two workable ideas.

I can either hack the arduino package as you suggested, adding the Polulu info to boards.txt and programmers.txt files, or I can copy the contents of the cores directory that’s inside the arduino package and replicate it in my arduino sketches directory, renamed appropriately. The first option sounds easier, so that’s what I’ll try. If it works, I just need to remember to re-hack any updates.

I don’t think this is the way the arduino developers intended to accommodate third-party hardware, but it feels like they haven’t banged hard on this type of scenario.

I’ll let you know what happens.

It worked! Thanks a lot.

I had trouble with the new arduino 1 release — not sure if I made a mistake or if it’s not ready for Polulu — so I reverted to arduino 021 and hacked its internal boards.txt and programmers.txt files.

Voila! I compiled and uploaded some simple LED examples, no problem, then compiled and uploaded the PID Line Follower program. Smooth!

Thanks again, Kevin.

Not to be or ornery, but you did exactly what I told you to, and viola! it worked. Not sure why you thought it wouldn’t.

While technically the 3pi is third party hardware, it is the same chip (atmega328p) as the standard Arduinos, so it uses the same core. You would create a new folder in the hardware directory if you wanted a different core, such as for an atmega644, or PIC32 (ChipKit).

Also, Arduino 1.0 works fine with the 3pi (and Baby Orang.) I had to add one line to what Pololu already had for boards.txt:

############################################################## Orangutan or 3pi robot w/ ATmega328p via Programmer

And you still need to add this to ISP v2 avrispv2.communication=serial avrispv2.protocol=avrispv2With those additions, 1.0 works fine. Just make sure you have the correct serial port selected.

Oh, and my name isn’t Dave… If you don’t like saying “Darth Maker”, then “Darth”, “DM” and “blue” (unrelated, and don’t ask) will also do.

Thanks for your help, Darth.

One aspect of the patch that confused me is that the Mac OS X version of the arduino application is structured differently. The package path to the boards.txt and programmers.txt files is

This morning I successfully modified arduino 023, but I still can’t get arduino 1.0 to work with the Polulu boards, even using your addition to boards.txt.

Not a problem.

Can you be a bit more specific about how it’s not working? Post error messages, both normal and verbose (shift-click verify). Or if you don’t get an error message, tell us exactly what’s happening, and what’s not.

And just to be certain, you did add avrispv2 to the programmers.txt file, right?

Some sketches compile OK (OrangutanBlinkExample), some don’t (PID3piLineFollower, OrangutanBuzzerExample). For the latter, I see this error message:

For PID3piLineFollower, I see this:

All of these compile OK with earlier versions of arduino.

The arduino 1.0 I’m using is modified with the boards.txt and programmers.txt files from Polulu and with your additional line in boards.txt.

Ah, that is a very different problem. This is due to the Pololu Orangutang libraries not being updated to 1.0 yet.

I’m not sure about the Orang buzzer example error. Since the other examples for that lib compile fine, I guess that there may be a problem with the sketch/program itself.

For the second error, you will need to edit each of the offending files to include <Arduino.h> instead of “wiring.h”. This error will show up on the LCD, QTR, and pushbutton libs, and possible one or two others.
[You can now download them in the attached zip file, but I do suggest you read through this anyway if it’s new to you.]
Here are the lines to change:

#ifndef ARDUINO
#include "../OrangutanTime/OrangutanTime.h"
#include "wiring.h"		// provides access to delay() and delayMicroseconds()
#endif[/code]That needs to be changed to this:[code]#ifndef ARDUINO
#include "../OrangutanTime/OrangutanTime.h"
#include <Arduino.h>
//#include "wiring.h"		// provides access to delay() and delayMicroseconds()

I only comment out the wiring include because you will need to change it back to use the library with any pre-1.0 Arduino IDEs.

You can basically just run/verify an example from each library. If it needs that change, you will get that error:

Error compiling.
/Users/petej/Documents/Arduino/libraries/PololuQTRSensors/PololuQTRSensors.cpp:57:75: error: wiring.h: No such file or directory
/Users/petej/Documents/Arduino/libraries/PololuQTRSensors/PololuQTRSensors.cpp: In member function 'void PololuQTRSensorsRC::readPrivate(unsigned int*)':
/Users/petej/Documents/Arduino/libraries/PololuQTRSensors/PololuQTRSensors.cpp:583: error: 'delayMicroseconds' was not declared in this scope

The number 57 in the error tells you what line number has the offending code. In this case it points you exactly where you need to go to make the above change. This will be true with the other libraries also when they give that error.

Hopefully Pololu will update their libraries soon for the official download. They probably need to thoroughly test the code though first, which is understandable. So far, making the changes I described has worked perfectly for me, but this is not well tested code.

You said the code was compiling ok, but you are also able to upload to the 3pi from 1.0 right?

Well, I just attached all my edited Pololu LIBs to the post in a ZIP. Also pseudo-randomly included is the updated L3G4200D Lib, which I happened to do when I needed it a couple days ago.
@Pololu, I suggest you guys take a look at these. (106 KB)

Thanks, Darth. I was afraid it was something I’d done wrong. :frowning:

I’ll update the libraries and see if the errors disappear. I didn’t try to upload the compiled code to the 3pi. but I’ll check that out today.

hi -

sorry to revive a solved thread, but i’m having the same problem as petej.

i’m on a macbook pro, running Lion, and, like petej, everything i program for the arduino is fine. however, i am unable to compile/program the 3pi and the errors i get tell me that when i try to compile for the 3pi arduino can’t find its core files.

my method is to >>

tools>board>pololu orangutan or 3pi……
tools>serial port>/dev/tty.usb……


i tried kevin’s solution (above) in arduino 0022, but get the following errors:

in 1.0.1 i get:

i have downloaded and installed dm’s zipped lib for 1.0, and have tried the official, current pololu release, and get the same results.

as a last example, if i try to compile the Simple3piMazefollower i get these errors:

any advice greatly appreciated.


When he got that error, it was due to creating a new folder under /hardware. Don’t create a new folder, just modify boards.txt and programmers.txt in the arduino folder.

thanks - everything works!

for anyone else who might find this thread, the problem i had was that another contributed arduino hardware library had created versions of boards.txt and programmers.txt inside of their folder inside the documents>arduino>hardware directory.

by removing those files and restarting arduino everything is well with 3pi. when i need the other library, which won’t run without its own boards.txt and programmers.txt (even if i copy the contents into the boards.txt and programmers.txt in crtl-Arduino>show package contents>contents…etc.) i just drag the other boards and programmers files back, restart arduino, and they’re fine.