11

(Marcin) #1

TUTORIAL


Monkey skull treasure bowl


CAPACITIVE SENSING


The capacitive sensors on the Gemma work by
charging and discharging the output pins and
measuring the voltage. The pins have a small amount
of capacitance and the microcontroller is sensitive
enough to measure this. When a person is very
near to the sensor, they affect the circuit by acting
as a second capacitor. This means that when the
microcontroller charges and discharges the pin, it
will see a change in behaviour and know that it has
been touched.

Above
LEDs only work if the
current flows from
anode to cathode
Below
Schematic

LED. Make a note of which wire connects to the
anode of the LED.
Use a bradawl or skewer to make a hole in the
back of the eye sockets and into the cardboard box.
Pass the wires through the holes and out of the box.
Crimp a resistor to one of the LED wires.

YOU’VE GOT THE TOUCH
The sensor for the touch is formed from the
screening from the screened wire. Remove the
outer plastic cover of the screened wire and slide
the braided screen off the wires. Flatten the braid
and form into a loop to fit around the rim of the
bowl. Twist the ends together and crimp to a
wire. Make a hole from the bowl through to the
electronics box and pass the wire though. The braid
can then be attached to the bowl with hot glue.
Strip the ends of the wire and wrap around an
M2.5 bolt, and twist the end to form a loop. Form a
loop on the end of each resistor. Bolt one LED anode
wire to the D0 connection on the Gemma, and the
other anode wire to D2. The cathode wires should
be bolted to the 0 V connector. Bolt the sensor wire
to the A0 connection.

BRAIN POWER
The Gemma M0 uses an ATSAMD21E18 processor,
and this is powerful enough to run a subset of the
Python language called CircuitPython. Combined
with the provided libraries, this means we can build
this kind of project with just a few lines of code.

import time
import board
import touchio
from digitalio import DigitalInOut, Direction

We start with instructions to use the libraries for
time, board, and touchio. For the digitalio import
instruction, we’ve just picked the items we need.
Free download pdf