# Gemma-Powered NeoPixel LED Sound Reactive Drums

## Overview

http://youtu.be/WwKis1vek0U

Light up your drums with sound! This guide will help you upgrade your drums to have sound reactive LEDs. This build uses a mic amp sensor and Gemma to light up NeoPixels to the beat of your drums. The cost of this build is considerably lower than other kits. Its also compact, rechargable and mobile!

![](https://cdn-learn.adafruit.com/assets/assets/000/012/639/medium800thumb/gemma_adafruit_products_drum-slide-out.jpg?1448311340)

We made a circuit for a snare, mid-tom, hi-tom and a drum kick. Each drum is independent from one another but can also trigger other pieces if struck loud enough. Our project cost one third of the price of other led drum kits on the [market](https://www.google.com/search?q=led+drum+kit&client=safari&rls=en&source=lnms&sa=X&ei=VJCeUuKUKIbakQeVroDQCQ&ved=0CAUQ_AUoAA&biw=1584&bih=979#q=led+drum+lights&rls=en)! There are other [tutorials](http://www.instructables.com/tag/type-id/?sort=none&q=led+drum "Link: http://www.instructables.com/tag/type-id/?sort=none&q=led+drum") out there that use a Piezo element and several components (capacitors, resistors, timers, etc) but our tutorial is a lot easier to achieve with Adafruit's low-cost and powerful micro-controllers, sensors and LEDs.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/644/medium800thumb/gemma_led-drums.jpg?1448311348)

## Prerequisite guides

- [NeoPixel Überguide](http://learn.adafruit.com/adafruit-neopixel-uberguide "Link: http://learn.adafruit.com/adafruit-neopixel-uberguide")[  
](http://learn.adafruit.com/adafruit-neopixel-uberguide)
- [Getting Started with Gemma](http://learn.adafruit.com/introducing-gemma)&nbsp;or [Gemma M0](https://learn.adafruit.com/adafruit-gemma-m0)

## Tools & Supplies

- [Soldering iron](http://www.adafruit.com/index.php?main_page=adasearch&q=soldering+iron "Link: http://www.adafruit.com/index.php?main\_page=adasearch&q=soldering+iron")
- Solder
- [Scissors](http://www.adafruit.com/products/1599 "Link: http://www.adafruit.com/products/1599")
- [Wire stripers](http://www.adafruit.com/products/527)
- [Wire spool set](http://www.adafruit.com/products/1311 "Link: http://www.adafruit.com/products/1311")
- Double sided foam tape
- Paper tape
- [3D Printer](http://www.adafruit.com/products/1292) (optional)

## Parts

- Drum Set
- [Gemma](http://www.adafruit.com/products/1222)&nbsp;or [Gemma M0](https://www.adafruit.com/product/3501)&nbsp;microcontroller
- [Mic Amp](http://www.adafruit.com/products/1063)
- [Slide Switch](http://www.adafruit.com/products/805)
- [Lithium Polymer Battery](http://www.adafruit.com/products/1578)
- [NeoPixel Strips](http://www.adafruit.com/index.php?main_page=adasearch&q=neopixel+strip)

# Gemma-Powered NeoPixel LED Sound Reactive Drums

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/012/651/medium800/gemma_drums-circuit-Layout.jpg?1386105343)

## Prototype Circuit

It's good protocol (& wise engineering!) to prototype your circuits before soldering permanently. You can use small alligator clips to connect the components temporarily. The pins on the mic sensor are small, so be sure to double check your connections if your having trouble getting the circuit to work. It might be easier to solder wires to the mic and then alligator clip to those. Since drumsets are so loud, the code is set to have a low sensitivity for the mic, so make sure to give a loud sound when testing the NeoPixels audio response. Rubbing the microphone with your finger is a good way to get a reaction.  
  
The NeoPixel strips digital input connects to pin **D0** of the Gemma. The negative connection of the NeoPixel strip goes to the ground pin on the Gemma. The positive power wire of the NeoPixel LED strip connects to the **VBat** pin of the Gemma (not 3.3V!) The out pin on the mic amp goes to pin **A1/D2** of the Gemma - this is an anolog input pin. The positive power breakout pin on the mic amp will connect to the 3.3v pin of the Gemma since it is a clear power source than VBat, the voltage goes through the onboard regulator. The negative ground pin of the mic amp can share the same ground connection on the Gemma (together with the NeoPixel strip).

This project can work with either the original Gemma or the newer Gemma M0. A 3V Trinket board is also an option, but _not_ the 5V variety…the circuit relies on the 3.3V regulator present on these other boards.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/680/medium800/gemma_prototype.jpg?1386121296)

## The Code

The Gemma is programmed via USB with the Arduino IDE. You can modify and customize the code to fit your setup. For starters, we can easy change the pin outs and number of NeoPixels. In our setup, each drum used 60 NeoPixels for each drum piece.   
  
If your new to using the Gemma and the Arduino IDE, check out [this guide](http://learn.adafruit.com/introducing-gemma/setting-up-with-arduino-ide) for setting up. Have some extra time on your hands? Learn how to [customize](http://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library) the code to change the color!

```auto
/* Sound-Reactive Drums for Adafruit Gemma/Trinket and NeoPixel LEDs.

Hardware requirements:
 - Adafruit Gemma, Gemma M0, or 3V Trinket microcontroller.
   Do NOT use a 5V Trinket; circuit DEPENDS on the 3V regulator!
 - Adafruit Electret Microphone Amplifier (product ID: 1063)
 - A length of NeoPixel LEDs, such as:
   o Adafruit Flora RGB Smart Pixels (ID: 1260)
   o Adafruit NeoPixel Digital LED strip (ID: 1138)
   o Adafruit Neopixel Ring (ID: 1463)
 - Lithium-polymer battery (such as 1578, but other sizes OK) and charger (1304)

Software requirements:
 - Adafruit NeoPixel library

Connections:
 - 3Vo (3V) to mic amp +
 - Vout (5V) to NeoPixel +
 - GND to mic amp - and NeoPixel -
 - Mic OUT to analog pin (configurable below)
 - Neopixel IN to digital pin (configurable below)
 Disconnect USB after programming; audio input requires clean DC from battery.

Written by Adafruit Industries.  Distributed under the BSD license.
This paragraph must be included in any redistribution.
*/

#include <Adafruit_NeoPixel.h>

#define LED_PIN      0 // NeoPixel LED strand is connected to D0
#define N_PIXELS    60 // Number of NeoPixels in strand
#define MIC_PIN     A1 // Microphone connects to A1 (aka D2)
#define DC_OFFSET    0 // DC offset in mic signal - if unusure, leave 0
#define NOISE       90 // Noise floor in mic signal
#define SAMPLES     50 // Length of buffer for dynamic level adjustment
#define BRIGHTNESS 255 // 0 (off) to 255 (max brightness)

int  lvl[SAMPLES];     // Save up recent mic readings
int  damp      = 10;   // Current "dampened" audio level
int  minLvlAvg = 0;    // For dynamic adjustment of graph low & high
int  maxLvlAvg = 512;
byte counter   = 0;    // Array index for storing recent mic readings

Adafruit_NeoPixel strip(N_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  memset(lvl, 0, sizeof lvl); // Clear lvl[] array to 0
  strip.begin();              // Initialize NeoPixels
}

void loop() {
  int n = analogRead(MIC_PIN);          // Raw reading from mic
  n = abs(n - 512 - DC_OFFSET);         // Center on zero, rectify to 0-512
  n = (n <= NOISE) ? 0 : (n - NOISE);   // Remove noise/hum
  lvl[counter] = n;                     // Save value for dynamic leveling
  if(++counter >= SAMPLES) counter = 0; // Increment array index, roll over if needed

  damp = ((damp * 7) + n + 3) / 8; // "Dampened" mic reading (else looks twitchy)

  // Calculate upper/lower range of prior mic readings
  uint16_t minLvl = lvl[0], maxLvl = lvl[0];
  for(uint8_t i = 1; i < SAMPLES; i++) {
    if(lvl[i] < minLvl)      minLvl = lvl[i];
    else if(lvl[i] > maxLvl) maxLvl = lvl[i];
  }
  // minLvl and maxLvl indicate the mic range over prior readings, used
  // for vertically scaling the output graph (so it looks interesting
  // regardless of current volume level).  If they're too close together
  // though (e.g. at very low volume levels) the graph becomes super
  // coarse and 'jumpy'...so keep some minimum distance between them
  // (this also lets the graph go to zero when no sound is playing):
  if((maxLvl - minLvl) < N_PIXELS) maxLvl = minLvl + N_PIXELS;
  minLvlAvg = (minLvlAvg * 63 + minLvl + 31) / 64; // Dampen min/max levels
  maxLvlAvg = (maxLvlAvg * 63 + maxLvl + 31) / 64; // (fake rolling average)
  // Bar height based on dampened reading scaled by dynamic min/max levels:
  int height = N_PIXELS * (damp - minLvlAvg) / (long)(maxLvlAvg - minLvlAvg);
  if(height < 0)             height = 0;  // Clip to strand bounds
  else if(height > N_PIXELS) height = N_PIXELS;

  // Color NeoPixels based on above calculations & apply rainbow gradient.
  strip.fill(0); // Clear everything, easier than setting individual pixels
  for(uint8_t i = 0; i < height; i++) { // For each pixel up to 'height'...
    // Use the ColorHSV function to produce a rainbow of hues. 20000 is
    // green-ish, the -40000 proceeds "backwards" through the color wheel,
    // with red at 0 and a magenta-ish hue around -20000. This is explained
    // in more depth on the "Arduino Library Use" page of NeoPixel Uberguide.
    strip.setPixelColor(i, strip.ColorHSV(20000 - 40000 * i / strip.numPixels(), 255, BRIGHTNESS));
  } 

  strip.show(); // Update NeoPixels
}
```

# Gemma-Powered NeoPixel LED Sound Reactive Drums

## 3D Printing

![](https://cdn-learn.adafruit.com/assets/assets/000/012/649/medium800/gemma_print-parts.jpg?1386105071)

Our three piece design will house the gemma, a recharger battery and the slide switch. The cover is designed to mount a slide switch on top for easy powering access. The cover snaps onto the top of the case. The hanger can be attached to the back of the base. The hanger has a hole that fits into standard sized drum shell pins. The case design is slim and non-intrusive while playing and doesnt look like an eye-sore in transparent PLA material.

[Download STL](http://www.thingiverse.com/thing:195471)
Download and print each part with the following settings:

# Printing Techniques
**Build Plate Preparations**  
There's a great [video tutorial](http://www.youtube.com/watch?v=VDnBXpFa7DY) by Dr. Henry Thomas who demonstrations a great technique for preparing acrylic build plates for awesome prints. Wipe down the plate with a paper towel lightly dabbed in acetone. Use another paper towel and apply a tiny dab of olive oil. Wipe down the plate so a small film of oil is applied, this will allow the parts to come off the plate easier.  
  
**Live Level**  
We recommend going raft-less for each piece because it will have the best quality result. Each piece will require a well leveled platform. We tend to "live level" our prints, meaning we adjust the build plates thumb screws while the print is laying down filament. This way we can make adjustments directly and improve the leveling by seeing how the extruders are laying down the first layer onto the build plate. We recommend watching the first layer so that you get a more successful print. If you see the layers aren't sticking or getting knocked off, you can always cancel print, peel it off and try again. Once your pieces are printed, test out to see if the cover tightly snaps onto the case. Check to see if the slide switch fit through the cutout on the cover. If its too tight, you can use an X-Acto knife to shave off the edges. If its too lose, you can secure it in place with adhesive. The hanger will be attached to the back of the case later with doubled-sided foam tape. Set these pieces aside for now. It's time to solder some components!

# Gemma-Powered NeoPixel LED Sound Reactive Drums

## Build

![](https://cdn-learn.adafruit.com/assets/assets/000/012/672/medium800/gemma-pins.jpg?1386114257)

Once you have your circuit prototype tested and working, you will need to solder wires to these components for a solid connection. You should start by measuring lengths of wires needed for connecting the Gemma to the NeoPixels and mic sensor. The wires should be long enough to run through the air hole and inside the drum shell. The main circuit (which contains the gemma, battery and switch) will be fitted inside an enclosure and mounted on the side of the drum shell closest to the air hole. To see if your wires are long enough, place the Gemma into position and see if the wire is long enough to connect the NeoPixel strips inside the drum shell. It's fine to have some extra wire.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/671/medium800/gemma_neopixel-pins.jpg?1386113664)

The NeoPixel strip will need three wires soldered to the beginning of the pixel strip. Solder a black wire to the GND pin. A blue wire to the DIN pin. And a red wire to the positive +5V pin. The length of these three wires can be short because we can use alligator clips to connect them to the longer wires that will be soldered to the Gemma.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/645/medium800/gemma_assemble.jpg?1386104682)

The NeoPixel strips will be mounted to the inner lining of the drum shells. You can measure and cut the length of an LED strip needed to cover the whole shell. Use the indictor on the strip to cut them properly. Position the first LED pixel closest to the air hole of the shell. The wires at the end of the strip should remain inside the shell.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/676/medium800/gemma_neopixel-mount.jpg?1386117416)

You can choose how deep you want your lights to be in the shells. For the drum kick, we positioned them away from the drum pedal so it's brighter when facing an audience. In the tom toms and the snare, the LEDs are positioned closer to the drummer, but you can mount them closer to the bottom for the audience. You can use paper tape to keep the strips mounted to the inner lining. We can do this after we solder wires to the NeoPixel strips.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/679/medium800/gemma_mic-pins.jpg?1386120734)

Three short wires will need to be soldered to the break out pins. Once soldered, position the mic sensor inside the shell. The mic sensor will be mounted to the inside of the shell with paper tape. Use alligator clips to connect to the mic sensor wires to the Gemma enclosure that is outside of the drum through the air hole.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/675/medium800/gemma-case.jpg?1386117316)

With the wires soldered to the gemma, you can fit each cable through the small slit on the side of the case. Carefully bend the wires down towards the opening of the case for a good fit. You can stick a small piece of doubled-sided foam tape to keep the bottom of the Gemma secured it in place.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/677/medium800/gemma_case-switch.jpg?1386117475)

The battery should be positioned inside of the case on top of the Gemma. The slide switch can be positioned through the cutout on the enclosure cover. You can use an adhesive to secure the slide switch.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/674/medium800/gemma_case-mount.jpg?1386116692)

Attach the hanger to the back of the case with a piece of double-sided foam tape. Position the hole on the hanger above the shell pin and press it down to mount it into place.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/646/medium800/gemma_assemble2.jpg?1386104782)

Once you have all of the parts mounted and secured to the shells, play and test out each piece. If you have issues with the LEDs, make sure your battery is fully charged and check your alligator clip connections to see if any wires are touching. The amount of sensitivity will vary depending on where you position the mic sensor.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/648/medium800/gemma_cable-tube.jpg?1386104944)

We used pieces of cable tube organizers to protect the exposed wired. You can also use shrink tubing for a more permanent finish.

![](https://cdn-learn.adafruit.com/assets/assets/000/012/665/medium800/gemma_cases.jpg?1386107400)

The lithium polymer batteries can be removed and recharged. They should last about an hours worth of play time. You can alternatively use a bigger battery pack for a longer sessions. The cases are non-intrsutive to the look of the drums and the wires and sensor inside the shells don't have an overall change to the sound. Since each drum is independent of each other, you can break down your set without having to worry about disconnecting any wires!  
  
Made an awesome upgrade? Let us know!! Stop by our weekly show-n-tell on [youtube](http://youtube.com/adafruit/), Saturdays at 9:30 PM EST and show off your upgrade to Lady Ada her self (and thousands of people LIVE) also WIN a FREE As Seen on Show-N-Tell Adafruit sticker! Post a comment on our [google+](https://plus.google.com/+adafruit) page in our show related post and we'll invite you!


## Featured Products

### Adafruit GEMMA v2 - Miniature wearable electronic platform

[Adafruit GEMMA v2 - Miniature wearable electronic platform](https://www.adafruit.com/product/1222)
 **Deprecation Warning: The Gemma bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Gemma so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1222)
[Related Guides to the Product](https://learn.adafruit.com/products/1222/guides)
### Arduino GEMMA - Miniature wearable electronic platform

[Arduino GEMMA - Miniature wearable electronic platform](https://www.adafruit.com/product/2470)
What do you get when you combine&nbsp;an Adafruit classic with geniuses at Arduino? The Arduino GEMMA!&nbsp;It's a tiny wearable platform board with a lot of might in a 1" diameter package. Powered by a Attiny85 and programmable with an Arduino IDE over USB, you'll be able to...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2470)
[Related Guides to the Product](https://learn.adafruit.com/products/2470/guides)
### Adafruit Metro M4 feat. Microchip ATSAMD51

[Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382)
Are you ready? Really ready? Cause here comes the fastest, most powerful Metro ever. The **Adafruit Metro M4** featuring the **Microchip ATSAMD51**. This Metro is like a bullet train, with its 120MHz Cortex M4 with floating point support. Your code will zig and zag...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3382)
[Related Guides to the Product](https://learn.adafruit.com/products/3382/guides)
### Adafruit NeoPixel Digital RGB LED Strip - White 30 LED

[Adafruit NeoPixel Digital RGB LED Strip - White 30 LED](https://www.adafruit.com/product/1376)
You thought it couldn't get better than [our world-famous 32-LED-per-meter Digital LED strip](http://adafruit.com/products/306) but we will prove you wrong! These NeoPixel strips have 30 digitally-addressable pixel LEDs per meter and are very affordable and are only 12.5 mm...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1376)
[Related Guides to the Product](https://learn.adafruit.com/products/1376/guides)
### Electret Microphone Amplifier - MAX4466 with Adjustable Gain

[Electret Microphone Amplifier - MAX4466 with Adjustable Gain](https://www.adafruit.com/product/1063)
Add an ear to your project with this well-designed electret microphone amplifier. This fully assembled and tested board comes with a 20-20KHz electret microphone soldered on. For the amplification, we use the Maxim MAX4466, an op-amp specifically designed for this delicate task! The amplifier...

In Stock
[Buy Now](https://www.adafruit.com/product/1063)
[Related Guides to the Product](https://learn.adafruit.com/products/1063/guides)
### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

In Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
### Hook-up Wire Spool Set - 22AWG Solid Core - 6 x 25 ft

[Hook-up Wire Spool Set - 22AWG Solid Core - 6 x 25 ft](https://www.adafruit.com/product/1311)
Perfect for bread-boarding, free wiring, etc. This box contains 6 spools of solid-core wire. The wire is easy to solder to and when bent it keeps its shape pretty well. We like to have a few spools of this stuff around which is why this set is quite nice! We suggest picking up wire strippers...

In Stock
[Buy Now](https://www.adafruit.com/product/1311)
[Related Guides to the Product](https://learn.adafruit.com/products/1311/guides)

## Related Guides

- [Adafruit Metro M4 Express featuring ATSAMD51](https://learn.adafruit.com/adafruit-metro-m4-express-featuring-atsamd51.md)
- [GEMMA Hoop Earrings](https://learn.adafruit.com/gemma-hoop-earrings.md)
- [NeoPixel NanoRing](https://learn.adafruit.com/neopixel-nanoring-gemma.md)
- [Unibeam](https://learn.adafruit.com/unibeam.md)
- [Introducing Gemma](https://learn.adafruit.com/introducing-gemma.md)
- [Costume Triggers & Actuators](https://learn.adafruit.com/costume-triggers-and-switches.md)
- [Bunny Ears with MakeCode](https://learn.adafruit.com/bunny-ears-with-makecode.md)
- [Trinket / Gemma Space Invader Pendant](https://learn.adafruit.com/trinket-slash-gemma-space-invader-pendant.md)
- [A Logger for CircuitPython](https://learn.adafruit.com/a-logger-for-circuitpython.md)
- [Building CircuitPython](https://learn.adafruit.com/building-circuitpython.md)
- [Ursula's Seashell Necklace](https://learn.adafruit.com/ursulas-seashell-necklace.md)
- [Make It Talk](https://learn.adafruit.com/make-it-talk.md)
- [Cyberpunk Spikes](https://learn.adafruit.com/cyberpunk-spikes.md)
- [FLORA and GEMMA ICSP](https://learn.adafruit.com/flora-and-gemma-isp.md)
- [Tiny Arduino Music Visualizer](https://learn.adafruit.com/piccolo.md)
- [Native MP3 decoding on Arduino](https://learn.adafruit.com/native-mp3-decoding-on-arduino.md)
