Contents • vii
What If It Doesn’t Work? 110
Exercises 110
7. Writing a Game for the Motion-Sensing Game Controller . 111
Writing a GameController Class 112
Creating the Game 114
What If It Doesn’t Work? 124
Exercises 124
8. Generating Video Signals with an Arduino . . . . . 127
What You Need 128
How Analog Video Works 128
Building a Digital-to-Analog Converter (DAC) 130
Connecting the Arduino to Your TV Set 131
Using the TVout Library 133
Building a TV Thermometer 134
Working with Graphics in TVout 139
What If It Doesn’t Work? 143
Exercises 144
9. Tinkering with the Wii Nunchuk . . . . . . . 145
What You Need 145
Wiring a Wii Nunchuk 146
Talking to a Nunchuk 147
Building a Nunchuk Class 148
Using Our Nunchuk Class 152
Creating Your Own Video Game Console 153
Creating Your Own Video Game 153
What If It Doesn’t Work? 162
Exercises 162
10. Networking with Arduino . . . . . . . . . 163
What You Need 164
Using Your PC to Transfer Sensor Data to the Internet 164
Registering an Application with Twitter 167
Tweeting Messages with Processing 168
Communicating Over Networks Using an Ethernet Shield 173
Using DHCP and DNS 177
What If It Doesn’t Work? 180
Exercises 181
www.it-ebooks.info
Contents • viii
11. Creating a Burglar Alarm with Email Notification . . . 183
What You Need 184
Emailing from the Command Line 184
Emailing Directly from an Arduino 189
Detecting Motion Using a Passive Infrared Sensor 193
Bringing It All Together 197
What If It Doesn’t Work? 200
Exercises 200
12. Creating Your Own Universal Remote Control . . . . 201
What You Need 202
Understanding Infrared Remote Controls 202
Grabbing Remote Control Codes 203
Cloning a Remote 207
Controlling Infrared Devices Remotely with Your Browser 212
Building an Infrared Proxy 216
What If It Doesn’t Work? 223
Exercises 223
13. Controlling Motors with Arduino . . . . . . . 225
What You Need 225
Introducing Motors 226
First Steps with a Servo Motor 227
Building a Blaminatr 230
What If It Doesn’t Work? 235
Exercises 235
Part III — Appendixes
A1. Electronics and Soldering Basics . . . . . . . 239
Current, Voltage, and Resistance 239
Electrical Circuits 239
Learning How to Use a Wire Cutter 243
Learning How to Solder 243
Learning How to Desolder 247
A2. Advanced Arduino Programming . . . . . . . 249
The Arduino Programming Language 249
Bit Operations 251
www.it-ebooks.info