The MagPi - February 2020

(Greg DeLong) #1
the connections to the ribbon cable were made –
shown in Figure 11, along with where they connect
to a 20-pin header which fits onto the first pins
of Raspberry Pi’s GPIO. Note: pass the ribbon
connector through the slot in the base before
soldering up the 20-pin header socket. A small
wooden bar with foam glued on the back of it stops
the ribbon cable being pulled out.

13


Testing software
The simplesounds.py listing shows
some simple code that allows you to test all the
LEDs and trigger some simple sounds. There
is a sound for each of the six note triggers, as
well as the two control bars. The sounds were
taken from the Sonic Pi sample files, found at
/usr/share/sonic-pi/samples, and converted into
WAV files using Audacity. We will go more into
the details of what is needed next month, but this
software requires the installation of Adafruit’s
CircuitPython framework along with the MPR121
driver. We had no trouble installing this under
the Raspbian Buster operating system, but found
when we used earlier versions of the OS it did not
install correctly, throwing up errors.

Next month, we’ll look at software to drive the
touch sensor chip in a more reliable way and also
a fully fledged MIDI / sound sample keypad with
effects control, sequence recording, and playback.

11


Starting the circuit
The physical layout of this circuit is shown
in Figure 8. Start with the copper foil backing for
each sensor, which provides a good ground for the
sensors. Figure 9 shows a photograph of the foil,
with each strip connected by a small solder blob.
The foil was also kept in place using some blobs of
transparent Gorilla glue. Note the cut-out for the
touch sensor board screws; this was fitted on M2.5
screws and 5 mm M3 nylon spacers. Note that the
board was fitted with right-angle pins to keep a low
profile. The LEDs are pushed through the holes into
the cover, leaving them flush with the top surface.

12


Building the circuit
The resistors were mounted flat on the
board to the LEDs and, when all were wired up,
were held down in place by spots of hot-melt glue
in the LED holes. Then the touch sensor wires
were connected as shown in Figure 10. Finally,

3V3 (1)

Gnd (9)

SDA (3)

SCL (5)

GPIO 4 (7)

GPIO 22 (15)

GPIO 23 (16)

GPIO 24 (18)

GPIO 17 (11)

GPIO 18 (12)

GPIO 27 (13)

3V3 (1)

Gnd (9)

SDA (3)

SCL (5)

GPIO 4 (7)

GPIO 23 (16) GPIO 22 (15)

GPIO 24 (18)

GPIO 17 (11)

GPIO 18 (12)

GPIO 27 (13)
Hex-A-Pad

Raspberry Pi

Top Tip


Installing CircuitPython


In a command-line Terminal, type the following:
sudo apt update
sudo pip3 install --upgrade setuptools
sudo pip3 install adafruit-blinka
sudo pip3 install adafruit-circuitpython-mpr121

A small wooden bar with


foam glued on the back of


it stops the ribbon cable


being pulled out


Figure 10


Figure 11


Figure 10
Photograph
of wiring
Figure 11 Ribbon
connections to
Raspberry Pi’s
GPIO header

TUTORIAL


52 magpi.cc Make beats in style with Hex-A-Pad

Free download pdf