• Byte 1 contains the analog stick’s x-axis value, and in byte 2 you’ll find
the stick’s y-axis value. Both are 8-bit numbers and range from about 29
to 225.
• Acceleration values for the x-, y-, and z-axes are three 10-bit numbers.
Bytes 3, 4, and 5 contain their eight most significant bits. You can find
the missing two bits for each of them in byte 6.
• Byte 6 has to be interpreted bit-wise. Bit 0 (the least significant bit) con-
tains the status of the Z-button. It’s 0 if the button was pressed; otherwise,
it is 1. Bit 1 contains the C-button’s status.
The remaining six bits contain the missing least significant bits of the accel-
eration values. Bits 2 and 3 belong to the x-axis, bits 4 and 5 belong to Y,
and bits 6 and 7 belong to Z.
Now that you know how to interpret the data you get from the Nunchuk, you
can start to build a
Nunchuk
class to control it.
Improve People’s Lives with Tinkering
Because of its popularity, peripheral equipment for modern game consoles often is
unbelievably cheap. Also, it’s no longer limited to classic controllers; you can buy
things such as snowboard simulators or cameras. So, it comes as no surprise that
creative people have built many interesting projects using hardware that was origi-
nally built for playing games.
An impressive and useful tinkering project is the EyeWriter.
a
It uses the PlayStation
Eye (a camera for Sony’s PlayStation 3) to track the movement of human eyes.
A team of hackers built it to enable their paralyzed friend to draw graffiti using his
eyes. Because of a disease, this friend, an artist, is almost completely physically
paralyzed and can move only his eyes. With the EyeWriter, he can create amazing
artwork again.
It’s not an Arduino project, but it’s definitely worth a look.
a.
http://www.eyewriter.org/
Building a Nunchuk Class
The interface of our
Nunchuk
class (and the main part of its implementation)
looks as follows:
Tinkering/NunchukDemo/nunchuk.h
#ifndef __NUNCHUK_H__
Line 1
#define __NUNCHUK_H__
-
#define NUNCHUK_BUFFER_SIZE 6
-
Chapter 9. Tinkering with the Wii Nunchuk • 148
report erratum • discuss
www.it-ebooks.info