11

(Marcin) #1
FORGE

Left
Bolted connections
using washers and
2.5 mm bolts

OTHER IDEAS



  • Paint your skull in candy skull style for a ‘Day of
    the Dead’ look.

  • Use PWM to make the eyes fade up and down,
    rather than flash.

  • Use servos to make your skull move.

  • Swap out the Gemma with a Circuit Playground
    Express board, and add some audio effects to
    your project.


On the Gemma
M0, like many
microcontroller
boards, the pins are
shared and can do
different tasks.

This can be a useful technique to simplify the code QUICK TIP
you write later.


touch_pad = board.A0
touch = touchio.TouchIn(touch_pad)
led1 = DigitalInOut(board.D0)
led1.direction = Direction.OUTPUT
led2 = DigitalInOut(board.D2)
led2.direction = Direction.OUTPUT

The pins need to be configured before we can
use them. The A0 pin is configured for touch, D0
and D2 are configured as digital outputs. Note how
Direction and DigitalInOut don’t need a prefix as we
imported those specifically above.


def detected():
for i in range(3):
led1.value = True
led2.value = True
time.sleep(0.5)
led1.value = False
led2.value = False
time.sleep(0.2)

This code defines a function we can call when the
skull is triggered. It flashes the LEDs three times,
with a short delay between each flash.


detected()
while true:

if touch.value:
detected()
time.sleep(0.05)

To check that the lights are working, the code calls
the detected function when the Gemma first powers.
The while statement creates a loop that will keep
running until the power is turned off. It checks the
touch sensor to see if it has been touched. If it has,
then the code calls the function defined earlier to
flash the lights.
Upload the code to the Gemma and remove
the USB connector. Fit the batteries to the battery
pack, and plug into the Gemma. Test everything is
working, then fit the electronics into the back of the
skull. Add some treasure to the bowl, e.g. sweets.
Your monkey skull bowl is now ready for use.
Free download pdf