With less than 200 lines of code, you’ve written a complete game for your new
video game console. It’s definitely not a blockbuster, but it’s actually fun and
a great opportunity to learn about the very basics of game programming.
Also, it should give you enough confidence to implement more advanced
games. You can find a lot of classic games on the web that use nearly the
same hardware we used in this chapter.
3
What If It Doesn’t Work?
From a maker’s perspective, this chapter is an easy one. Still, things can go
wrong, especially with the wiring. Make sure you’ve connected the right pins
on the Arduino and on the Nunchuk. Also check that the wires tightly fit into
the Nunchuk’s and the Arduino’s sockets. When in doubt, use wire with a
larger diameter.
Also, check What If It Doesn’t Work?, on page 143, for all things that can go
wrong when generating video signals with the Arduino.
Exercises
• Rewrite the game we implemented in Chapter 7, Writing a Game for the
Motion-Sensing Game Controller, on page 111, so it supports the Nunchuk
controller. It should support both the analog stick and the accelerometer.
Perhaps you can switch between them using the Nunchuk buttons.
• Tinkering with Nintendo’s Wii Motion is more complicated.
4
But it’s a nice
and cheap way to sharpen your tinkering skills.
• The TVout library has basic audio support. Connect a piezo buzzer to
digital pin 11 and use the
tone
and
noTone
functions to add sound capabil-
ities to the video game console. Also, add some sound effects to Pragduino.
3. See
http://nootropicdesign.com/hackvision/games.html
.
4.
http://randomhacksofboredom.blogspot.com/2009/07/motion-plus-and-nunchuck-together-on.html
Chapter 9. Tinkering with the Wii Nunchuk • 162
report erratum • discuss
www.it-ebooks.info