Music & Sound

I’ve just started to learn C++ and programming for 3pi. I’ve managed to make minor mods to the Line Follower and Maze Solver demos, and am now working on some mods to allow the Maze Solver to be placed on any line segment and go to the end after it has done it’s first discovery run.

But I cannot figure out how to code to produce a specific series of musical notes. I also want to be able to make my robot talk. Maybe that’s impossible, but I don’t think so. For example, on talking, I’d like to make him say, when he gets to a dead-end, “Uh-Oh”, and other statements in other situations.

So, can anyone enlighten me on the issue of music and sound?


Check the programming guide for extensive functions to produce sound and music.

OK, I think I have it. I looked in the Pololu AVR Library Reference and saw various functions to produce frequencies and specific notes. But I also saw the sections all referred to Orangutan as opposed to 3pi. I take it that I use the green colored descriptive rather than the red. What is Orangutan, versus just 3pi.

Do I also assume that to output a voice like sound, let’s say the word HELLO, that I need to use the frequency player and determine the frequency of sounds in that word? If so, then I guess I’m going to need a program to interface my microphone to that will act like an oscilloscope and tell me the frequency shifts going on when that word is spoken. Or maybe a voice book that describes what frequencies make up letters or syllable’s. Sounds like a real challenge.

Speech would be difficult to figure out and implement by yourself. You can buy speech chips and modules that are programmed to utter words and phrases via one or more 3pi output pins. Here is one rather fancy example (google “speech chips” for others): … fault.aspx

That is slick. After thinking about it I understood how impossible it would be to produce even rudimentary speech from 3pi. But this looks very easy, other than the soldering required. Am I correct that there are enough pins available on the base 3pi to attach such a device to? Of course there’s no function in the library but I assume I could just develop the code to output, or receive, data from the chip. It looks also like the voltage requirement is within range of the batteries, though I’m not sure of the mA load nor the serial baud rate. But I can let that go for now, at least I know how to get the music done.

Thanks for the info.


The 3pi and Orangutan robot controllers both have AVR microcontrollers and much of the same hardware (the 3pi is like an Orangutan SV-328 with integrated motors and sensors), so the they share the same libraries. If you are programming in C++ or The Arduino IDE environments, you would use the methods shown in red. If you are using Atmel Studio as your programming environment, you would used the methods in green.

Also, the 3pi should work with the text to speech module Jim referenced. This can be done using the serial interface.


Thanks. I use Atmel, so green it is. I’ve got to practice a bit more before I work that speech chip, but now I know I can do it. Need to build up my coding skills and understand the Atmel platform better.