Hardware Reference
In-Depth Information
IN THIS CHAPTER you'll make use of the Twitter library to bring a soft toy to life. At the end
of this chapter, you can have your very own animatronic chicken that waddles and moves its
beak as it reads aloud tweets from a particular user or containing a certain hash tag.
his project illustrates that one of the joys of the Raspberry Pi is the ease of reusing existing
code. Programmers strive for eiciency (some people call it laziness) and aim to never type
the same thing twice. What's even better is never having to write the code in the irst place
and using someone else's!
his chapter will cover how to hack a toy to connect it to the Raspberry Pi and how to install
a Python module to talk to Twitter and interact with an external program (in this case a text-
to-speech engine) from Python.
Hacking the Toy
You are going to take an animated toy and “hack” it so the Raspberry Pi can control its movement.
You'll do this by wiring one of the relays on the PiFace interface to replace the toy's on-of switch.
The word hack in regard to computing has become associated with illegal activity. In this sense,
hacking is bad and not something to engage in. However, to programmers, a hack is a way to
make something work, particularly when reusing something or repurposing it in a clever way.
here are many animatronic and robotic toys available online and in novelty shops. It's easy
to modify the simple toys that have just a basic on-of switch. Before hacking your toy, it's
worth considering what happens if something goes wrong - it's best not to hack an expen-
sive toy or one you're particularly fond of, just in case you struggle to put it back together
again. You may wish to build your own toy from components instead.
Building the Chicken
I chose to build a twittering chicken around the Head and Mouth Mechanism shown in Figure
10-1 from Rapid Electronics ( www.rapidonline.com/Education/Head-and-mouth-
mechanism-60675 ) . he mechanism contains a battery case, a motor, gears and a switch. On
this web page, you'll ind a free data sheet with a fabric pattern for making the chicken cover (as
well as for a bird and a whale with other mechanisms).
Yellow fur for the body and red felt for the wattle and comb can be purchased from a local
fabric shop, and a local craft shop or market is an ideal hunting ground for suitable materials
like stick-on eyes. What's great about building your own toy is the opportunity for customisa-
tion - feel free to experiment. It shouldn't be too hard to modify the chicken pattern into the
Linux mascot “tux the penguin”. You could share your pattern online for other people too.
 
Search WWH ::




Custom Search