This mask reacts to sound! Five LED sequins are wired up to a GEMMA and microphone. In addition to the supplies listed on the first page, you will need:
- LED sequins in your favorite color
- GEMMA M0 or GEMMA v2 microcontroller
- MAX 9814 or MAX4466 electret microphone amplifier
You should also check out the following prerequisite guides:
- Introducing Gemma M0 or Introducing GEMMA
- Adafruit LED Sequins
- Adafruit Microphone Amplifier Breakout
- Adafruit AGC Electret Microphone Amplifier - MAX9814
and optionally take a look at these similar projects for inspiration:
By measuring audio levels in the room, we can use that measurement to control the brightness of the LEDs, giving a pulse-with-the-music effect! Use sewing pins to mock up your sequin design on the mask:
Check out the circuit diagram to get an idea of how the sequins can be arranged-- the positive sides (+) should all face the same way:
Wire connections are as follows:
- GEMMA GND to sequins (-)
- GEMMA D0 to sequins (+)
- Microphone GND to GEMMA GND
- Microphone Vdd to GEMMA 3V
- Microphone output to GEMMA A1
- 150mAh (or larger if desired) battery plugs in to GEMMA's JST port
You can run the wires over the front of the mask, like on the previous page, or you can run the wires on the back of the mask by punching or drilling holes for the wires to pass through. Remove the pinned sequins and drill two holes that match up with the hole spacing on the sequins.
Prep your microphone by tinning and soldering wires to the Vdd, GND, and outout pins.
pass wires through the holes of the mask, then strip and tin them before soldering to the sequins:
Once both positive and negative sides are soldered, pull the wires from the back so the sequin sits flush, then clip the leads with flush snips.
Find a place to put the microphone, which will be different on every mask. We found ajn opening in the fabric lace near the forehead that worked perfectly, but you could put it on the inside facing the wearer's mouth, or anywhere you like.
Solder the sequins and microphone up to GEMMA according to the circuit diagram.
Install a battery using velcro tape. Plug in GEMMA to your computer with a USB cable and make sure GEMMA's power switch is set to the ON position.
Load up this sample code using the Arduino software to get you started:
// SPDX-FileCopyrightText: 2017 Phillip Burgess for Adafruit Industries // // SPDX-License-Identifier: MIT // Sound level sketch for Adafruit microphone amplifier. // For the GEMMA sequin masquerade mask. #define SAMPLE_WINDOW 33 // Sample window width in mS (33 mS = ~30 Hz) #define LED_PIN 0 // DIGITAL pin # where LEDs are connected #define MIC_PIN A1 // ANALOG pin # where microphone "OUT" is connected void setup() { pinMode(LED_PIN, OUTPUT); } void loop() { // Listen to mic for short interval, recording min & max signal unsigned int signalMin = 1023, signalMax = 0; unsigned long startTime = millis(); while((millis() - startTime) < SAMPLE_WINDOW) { int sample = analogRead(MIC_PIN); if(sample < signalMin) signalMin = sample; if(sample > signalMax) signalMax = sample; } int peakToPeak = signalMax - signalMin; // Max - min = peak-peak amplitude int n = (peakToPeak - 10) / 4; // Remove low-level noise, lower gain if(n > 255) n = 255; // Limit to valid PWM range else if(n < 0) n = 0; analogWrite(LED_PIN, n); // And send to LEDs as PWM level }
CircuitPython Code
Below is CircuitPython code that works similarly to the Arduino sketch shown above. To use this, plug the GEMMA M0 into USB…it should show up on your computer as a small flash drive…then edit the file “main.py” with your text editor of choice. Select and copy the code below and paste it into that file, entirely replacing its contents (don’t mix it in with lingering bits of old code). When you save the file, the code should start running almost immediately (if not, see notes at the bottom of this page).
If GEMMA M0 doesn’t show up as a drive, follow the Introducing GEMMA M0 guide link above to prepare the board for CircuitPython.
# SPDX-FileCopyrightText: 2017 Phillip Burgess for Adafruit Industries # # SPDX-License-Identifier: MIT import time import analogio import board import pwmio sampleWindow = 0.033 # Sample window width (0.033 sec = 33 mS = ~30 Hz) ledPin = board.D0 # Pin where LEDs are connected (PWM not avail on D1) micPin = board.A1 # Microphone 'OUT' is connected here mic = analogio.AnalogIn(micPin) pwm = pwmio.PWMOut(ledPin, frequency=1000, duty_cycle=0) while True: # Listen to mic for short interval, recording min & max signal signalMin = 65535 signalMax = 0 startTime = time.monotonic() while (time.monotonic() - startTime) < sampleWindow: signal = mic.value if signal < signalMin: signalMin = signal if signal > signalMax: signalMax = signal peakToPeak = signalMax - signalMin # Audio amplitude n = (peakToPeak - 250) * 4 # Remove low-level noise, boost if n > 65535: n = 65535 # Limit to valid PWM range elif n < 0: n = 0 pwm.duty_cycle = n # And send to LED as PWM level
Now talk or play music for your mask, and see the LEDs change brightness with the volume!
Text editor powered by tinymce.