Posted on by & filed under Content - Highlights and Reviews, Web Development.

I had a great time building the Arduino Pieman project, as detailed here:
Meeting the Pieman: A Basic Arduino Memory Game.

But Pieman is so quiet. It needs a voice! A little searching pointed me to a great post that provides a nice little function for playing tones on a piezo.

Let’s plug that into Pieman.

After copying the playTone function from the article into your code, declaring your pinSpeaker and adding the pin mode for pinSpeaker to your setup, create an array of tones. Throw a couple dummy tones at the beginning so you can use the same indexes as your LED pins:

Now look for all the places that you’re turning an LED on, and add a playTone call using the LED’s pin value. You’re looking for two places. One is when you playback the sequence:

Another is when you’re handling button presses:

You should add a “Game Over” tone to resetPieman as well:

We have now successfully added a voice to Pieman!

Safari Books Online has the content you need

Here are some great Safari Books Online resources to help you add voice and other features to your Arduino projects:

Building electronic projects that interact with the physical world is good fun. But when the devices you’ve built start to talk to each other, things really get interesting. In Making Things Talk, Second Edition, author Tom Igoe shows how to make your Android gadgets communicate.
Arduino Internals doesn’t just focus on the different parts of Arduino architecture, but also on the ways in which example projects can take advantage of the new and improved Arduino board. Wheat employs example projects to exemplify the hacks and algorithms taught throughout the book.
Practical Arduino: Cool Projects for Open Source Hardware provides detailed instructions for building a wide range of both practical and fun Arduino-related projects, covering areas such as hobbies, automotive, communications, home automation, and instrumentation.

About the Author

  Duane O’Brien is a tired computer scientist. He has written a number of articles on developing web applications and various PHP frameworks. To learn more about Duane, check out his blog or read his tweets.

Tags: Arduino, piezo, voice,

Comments are closed.