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.
This project illustrates that one of the joys of the Raspberry Pi is the ease of reusing existing
code. Programmers strive for efficiency (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 first place
and using someone else's!
This 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 move-
ment. You'll do this by wiring one of the relays on the PiFace interface to replace the toy's
on-off 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.
NOTE
There 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-off 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 2-1 from Rapid Electronics ( www.rapidonline.com/Education/Head-and-
mouth-mechanism-60675 ). The mechanism contains a battery case, a motor, gears and a
switch. On this web page, you'll find 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). These writing
instructions make it easy to follow this chapter step by step. But you can substitute other
mechanisms.
 
Search WWH ::




Custom Search