The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

Tutorial


raspberrypi.org/magpi The Official Raspberry Pi Projects Book 135


SAVE


Figure 2 The full set
of controls on the DJ
Hero controller

Turntable – adjust parameter


Just pattern Full screen & Reset name


Redraw


Invert screen Select parameter to edit


Rotary – not used


Redraw depth Harmonic control Amplitude – Phase


Amplitude – Frequency


Damping


MAKE SCRATCH ART


extension wires to it, or get a small ‘Wii Nunchuk
adapter’ PCB and wire that to the Pi. Figure 1 shows
the wiring you need; as there are only four wires, you
can use a length of ribbon cable to attach it to the Pi,
with the cover neatly clipping over the top.


Language
>PYTHON 2

DOWNLOAD
THE CODE:
magpi.cc/1NqJjmV

PROJECT
VIDEOS
Check out Mike’s
Bakery videos at:
magpi.cc/1NqJnTz

Nunchuck


Adapter


+3V3 Gnd


Data I


(^2) C
GPIO 2
Clock I
(^2) C
GPIO 3
Figure 1 Wiring the Wii Nunchuk adapter to the Pi
Talking to the DJ Hero
The DJ Hero comprises a collection of buttons, knobs, a
joystick, and a turntable. Figure 2 shows these controls
labelled up as the functions they’re going to perform in
this project. The I^2 C address of this device is 0x52 and
consists of a number of registers. To initialise the device
on power-up, you must write the value 0x55 to register
0xF0. Note that each successive read will increment
the address of the register read from. So, to read the
interface status, you need to set the register to zero and
then read data six times – these six bytes contain the
information from the DJ deck. The assignment of bits is
shown in Figure 3 overleaf, and at first sight looks a bit
complex. Kowever, this diagram has been simplified, in
that the DJ Hero is capable of having a second turntable
on the left-hand side, and the bits corresponding to this
second turntable have been omitted.

Free download pdf