# Ursula's Seashell Necklace

## Overview

https://www.youtube.com/watch?v=9VwPc1W8sT4&amp;feature=youtu.be

Look at this shell. &nbsp;Isn't it neat? &nbsp;  
Wouldn't it just make your cosplay complete?  
Wouldn't they&nbsp;think you're the girl,  
The girl that has... everything?&nbsp;

Wear this necklace and it will respond to your beautiful Mermaid voice whenever you talk or sing. &nbsp;Use it to find your Prince, or to steal someone else's Prince if that's your bent. &nbsp;(Hey, it almost worked for Ursula. &nbsp;Ultimate Power Awaits.)

### Electronics

- [Flora](https://www.adafruit.com/product/659)
- [16 pixel Neopixel Ring](https://www.adafruit.com/product/1463)
- [150mAh LiPoly battery](https://www.adafruit.com/product/1317)
- [Electret Microphone breakout](https://www.adafruit.com/product/1063)
- [Micro Lipo charger for the battery](https://www.adafruit.com/products/1304)

### Tools

- 3D Printer
- Soldering iron & accessories
- Teensy weensy Philips head screwdriver

### Crafty Stuff

- Translucent gold paint (I used [Pebeo Vitrail Gold](http://www.amazon.com/Pebeo-Vitrail-Glass-Paint-45Ml/dp/B003YCEMV4))
- Elastic or necklace cord

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/024/259/medium800/sensors_led_pixels_seashell_guts.jpg?1427902207)

If you like this guide, also check out this [Seashell Necklace tutorial](../../../../circuit-playground-seashell-pendant/introduction)&nbsp;for a new twist on this project using our Circuit Playground board.

# Ursula's Seashell Necklace

## 3D Printing

![](https://cdn-learn.adafruit.com/assets/assets/000/024/099/medium800/led_pixels_IMG_3460.jpg?1427503000)

Print the seashell in white ABS. &nbsp;Get as much of the raft and supports as possible out from the inside -- you don't want that stuff blocking your lights.

&nbsp;Once it's done, paint it with gold or yellow translucent paint. &nbsp;I used two coats of [Pebeo Vitriol glass paint](http://www.amazon.com/Pebeo-Vitrail-Glass-Paint-45Ml/dp/B003YCEMV4)&nbsp;which gave it an almost carved-wood look, but any not-too-opaque paint should work.&nbsp;

[Download ursula_seashell.stl](http://www.thingiverse.com/thing:744504)
If you don't have a 3D printer, you can [get one printed&nbsp;at Shapeways](https://www.shapeways.com/product/3WJ7GPBW6/ursula-seashell-necklace?key=42f761a218731e1dd806d4e80631c55e). &nbsp;The internet is so great.

# Ursula's Seashell Necklace

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/024/096/medium800/led_pixels_circuit_diagram.jpg?1427500891)

- Flora VBAT --\> Neopixel 5V
- Flora D6 --\> Neopixel Data Input
- Flora GND --\> Neopixel Ground
- Flora GND --\> Microphone GND
- Flora D9 --\> Microphone Out
- Flora 3.3V --\> Microphone VCC

# Ursula's Seashell Necklace

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/024/098/medium800/led_pixels_IMG_3453.jpg?1427501701)

Cut all your wires to about 3" -- this will ensure you've got enough wiggle room to get everything situated in the shell but not have excess wire hanging around.

Stranded (flexible) wire will work best since you may need to flex the components around a bit to get them situated in the seashell.

On the neopixel ring, it's easiest to stick the wire in from the front and solder on the back to ensure you don't melt the LEDs or break anything.

Notice that there are two wires going to Flora's GND pad, so it will work best to twist them together at the ends and solder them in at the same time.

# Ursula's Seashell Necklace

## The Code

### Software Setup

If this is your first time using Flora, take a look at&nbsp;[Getting Started with Flora](../../../../getting-started-with-flora)&nbsp;to get a guided tour. &nbsp;&nbsp;

Once you've got Flora&nbsp;up and running with [Arduino](../../../../getting-started-with-flora/download-software), you'll need to install the **FastLED** library in Arduino (`Sketch > Include Library > Manage Libraries...`)

### Libraries? Why? What's a Library?

In a nutshell, Arduino libraries&nbsp;have&nbsp;a lot of pre-written functions that make your neopixels easy to command. &nbsp;You can do fancy stuff without being a code guru. Yay Libraries!

FastLED is a fast, efficient, easy-to-use Arduino library for programming addressable LED strips and pixels. &nbsp;It has a lot of features to get your animations up and running fast -- and it has a lot of code samples available if you're just learning to code.

[All about Arduino Libraries](../../../../adafruit-all-about-arduino-libraries-install-use/arduino-libraries)&nbsp;will&nbsp;tell you everything you ever wanted to know about libraries, including more detailed installation instructions.

Once your curiosity is satiated and your library is installed, copy and paste the code into your Arduino window.

Go to your Tools menu and select Flora&nbsp;from the list of boards. &nbsp;Plug your Flora&nbsp;into your computer via the onboard USB port. &nbsp;Press the "reset" button on your Flora&nbsp;and wait for the blinky red light, then click the upload button in Arduino.

```
/* soundbracelet for FastLED 2.1 or greater

Converted by: Andrew Tuline

Date: Oct, 2014

this code is based Neopixel code by John Burroughs:

https://www.youtube.com/watch?v=JjX8X5D8RW0&amp;feature=youtu.be
https://plus.google.com/105445034001275025240/posts/jK2fxRx79kj
http://www.slickstreamer.info/2014/07/led-bracelet-vu-meter-3dprinting.html

That was based on the Adafruit LED Ampli-tie project at:

https://learn.adafruit.com/led-ampli-tie/overview

This was written for a Sparkfun INMP401 MEMS microphone/pre-amp. In this case, it's plugged into A5 of the Arduino.

You may need to only use battery power as noise from the USB can affect the signals.

Plug Vcc of the microphone into 3.3V of Arduino. Connect 3.3V of Arduino to aref pin, and gnd to gnd.

FastLED is available at https://github.com/FastLED/FastLED

*/


#include "FastLED.h"                                          // FastLED library. Preferably the latest copy of FastLED 2.1.
 
// Fixed definitions cannot change on the fly.
#define LED_DT 6                                             // Serial data pin for WS2812B or WS2801
#define COLOR_ORDER GRB                                       // Are they RGB, GRB or what??
#define LED_TYPE WS2812B                                       // What kind of strip are you using?
#define NUM_LEDS 16                                           // Number of LED's

// Initialize changeable global variables.
uint8_t max_bright = 255;                                     // Overall brightness definition. It can be changed on the fly.

struct CRGB leds[NUM_LEDS];                                   // Initialize our LED array.


#define MIC_PIN 9                                             // Analog port for microphone

#define DC_OFFSET  0                                         // DC offset in mic signal - if unusure, leave 0
                                                              // I calculated this value by serialprintln lots of mic values
#define NOISE     100                                         // Noise/hum/interference in mic signal and increased value until it went quiet
#define SAMPLES   60                                          // Length of buffer for dynamic level adjustment
#define TOP (NUM_LEDS + 2)                                    // Allow dot to go slightly off scale
#define PEAK_FALL 10                                          // Rate of peak falling dot
 
byte
  peak      = 0,                                              // Used for falling dot
  dotCount  = 0,                                              // Frame counter for delaying dot-falling speed
  volCount  = 0;                                              // Frame counter for storing past volume data
int
  vol[SAMPLES],                                               // Collection of prior volume samples
  lvl       = 10,                                             // Current "dampened" audio level
  minLvlAvg = 0,                                              // For dynamic adjustment of graph low &amp; high
  maxLvlAvg = 512;


void setup() {
  
  // This is only needed on 5V Arduinos (Uno, Leonardo, etc.).
  // Connect 3.3V to mic AND TO AREF ON ARDUINO and enable this
  // line.  Audio samples are 'cleaner' at 3.3V.
  // COMMENT OUT THIS LINE FOR 3.3V ARDUINOS (FLORA, ETC.):
  //analogReference(EXTERNAL);

  delay(1000);                                                // Power-up safety delay or something like that.  
  Serial.begin(57600);
  LEDS.addLeds&lt;LED_TYPE, LED_DT, COLOR_ORDER&gt;(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
  set_max_power_in_volts_and_milliamps(5, 500);               // FastLED 2.1 Power management set at 5V, 500mA
} // setup()


 
void loop() {
  seashell();
  show_at_max_brightness_for_power();                         // Power managed FastLED display
  Serial.println(LEDS.getFPS()); 
} // loop()



void seashell() {

  uint8_t  i;
  uint16_t minLvl, maxLvl;
  int      n, height;
   
  n = analogRead(MIC_PIN);                                    // Raw reading from mic
  n = abs(n - 512 - DC_OFFSET);                               // Center on zero
  
  n = (n &lt;= NOISE) ? 0 : (n - NOISE);                         // Remove noise/hum
  lvl = ((lvl * 7) + n) &gt;&gt; 3;                                 // "Dampened" reading (else looks twitchy)
 
  // Calculate bar height based on dynamic min/max levels (fixed point):
  height = TOP * (lvl - minLvlAvg) / (long)(maxLvlAvg - minLvlAvg);
 
  if (height &lt; 0L)       height = 0;                          // Clip output
  else if (height &gt; TOP) height = TOP;
  if (height &gt; peak)     peak   = height;                     // Keep 'peak' dot at top
 
 
  // Color pixels based on rainbow gradient
  for (i=0; i&lt;NUM_LEDS; i++) {
    if (i &gt;= height)   leds[i].setRGB( 0, 0,0);
    else leds[i] = CHSV(map(i,0,NUM_LEDS-1,50,70), 255, 255);  //constrained to yellow color, change CHSV values for rainbow
  }
 
  // Draw peak dot  
  if (peak &gt; 0 &amp;&amp; peak &lt;= NUM_LEDS-1) leds[peak] = CHSV(map(peak,0,NUM_LEDS-1,50,70), 255, 255);

// Every few frames, make the peak pixel drop by 1:
 
    if (++dotCount &gt;= PEAK_FALL) {                            // fall rate 
      if(peak &gt; 0) peak--;
      dotCount = 0;
    }
  
  vol[volCount] = n;                                          // Save sample for dynamic leveling
  if (++volCount &gt;= SAMPLES) volCount = 0;                    // Advance/rollover sample counter
 
  // Get volume range of prior frames
  minLvl = maxLvl = vol[0];
  for (i=1; i&lt;SAMPLES; i++) {
    if (vol[i] &lt; minLvl)      minLvl = vol[i];
    else if (vol[i] &gt; maxLvl) maxLvl = vol[i];
  }
  // minLvl and maxLvl indicate the volume range over prior frames, used
  // for vertically scaling the output graph (so it looks interesting
  // regardless of 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) &lt; TOP) maxLvl = minLvl + TOP;
  minLvlAvg = (minLvlAvg * 63 + minLvl) &gt;&gt; 6;                 // Dampen min/max levels
  maxLvlAvg = (maxLvlAvg * 63 + maxLvl) &gt;&gt; 6;                 // (fake rolling average)

} // fastbracelet()
```

# If you encounter trouble…

Any time you&nbsp;hit a roadblock&nbsp;with a NeoPixel project, we’ll usually ask that you start with the “strandtest” example from our own Adafruit\_NeoPixel library. This helps us narrow down whether it’s a hardware or software issue. The library is installed similarly to FastLED or any other&nbsp;&nbsp;(`Sketch > Include Library > Manage Libraries...`)

You’ll find the strandtest example under **File→Sketchbook→Libraries→Adafruit\_NeoPixel→strandtest**

 **If strandtest fails to run, this suggests a hardware issue** …for example, connecting to the wrong input&nbsp;on the LED ring, or the wrong Flora&nbsp;pin.

If you’re new to Arduino programming and LEDs, we usually suggest starting with the Adafruit\_NeoPixel library…it’s pretty basic, the strip declaration is more conventional, and we can stay on top of keeping it compatible with our own products and the most mainstream Arduino boards.

As FastLED is a more “bleeding edge” third-party library, **we can’t always guarantee compatibility across versions or with specific boards.** You can find help through their **[community on Google+](https://plus.google.com/communities/109127054924227823508)**. This is potent stuff, written by people with a deep appreciation for LED art, and we wanted to showcase it.

# Ursula's Seashell Necklace

## Calibration

### Microphone Adjustment

You want the necklace to respond to your voice, but not go crazy at every little ambient noise. &nbsp;Some of this adjustment will happen in the code, but the nice thing about this mic breakout is that it has a teensy little adjustment screw. &nbsp;By configuring the code to respond to a medium gain, you'll have wiggle room to adjust on-the-fly for different environments. &nbsp;You'll be able to turn it down for noisy convention halls or up for quiet storytelling sessions.

Take&nbsp;your teeny weeny screwdriver and twist&nbsp;the gain adjustment screw until it's roughly in the middle of its turning radius.

![](https://cdn-learn.adafruit.com/assets/assets/000/024/101/medium800/led_pixels_adjustmentscrew.jpg?1427504322)

Now, make some noise. &nbsp;See how loud you need to be for your LEDs to respond. &nbsp;

Look at the code and find the value for NOISE. &nbsp;To make the mic more sensitive, make this number smaller. &nbsp;To make it less sensitive, make this number bigger. &nbsp;

# Ursula's Seashell Necklace

## Finishing

![](https://cdn-learn.adafruit.com/assets/assets/000/024/103/medium800/led_pixels_seashell_guts.jpg?1427504996)

Put it all together! &nbsp;

First, place the neopixel ring down. &nbsp;There's a star on the back of the ring -- that marks the first LED to light, so put this at the top.

Slip the microphone through into the "bell" part of the shell so it's facing up toward your face when you have the necklace on.

Coil the battery wire around and set it on top of the neopixel ring.

Pop the Flora into place on top of it all and thread your elastic or necklace cord through the ring at the top of the shell. &nbsp;It will all stay in place nicely (you don't need to glue anything) and you can carefully pop the battery cable out for charging.

Turn your necklace on and off with Flora's onboard on/off switch.&nbsp;

When you need to recharge, open the necklace back up. Disconnect the battery and charge using a [Micro Lipo Charger.](https://www.adafruit.com/products/1304)

![](https://cdn-learn.adafruit.com/assets/assets/000/024/102/medium800/led_pixels_IMG_3465.jpg?1427504633)

You may notice that your calibration / sensitivity changes when the mic is inside the seashell. &nbsp;Adjust it with the screw or in the code until you feel the magic.


## Featured Products

### FLORA - Wearable electronic platform: Arduino-compatible

[FLORA - Wearable electronic platform: Arduino-compatible](https://www.adafruit.com/product/659)
FLORA is Adafruit's fully-featured wearable electronics platform. It's a round, sewable, Arduino-compatible microcontroller designed to empower amazing wearables projects.FLORA comes with Adafruit's support, [tutorials and...](http://learn.adafruit.com/category/flora)

In Stock
[Buy Now](https://www.adafruit.com/product/659)
[Related Guides to the Product](https://learn.adafruit.com/products/659/guides)
### NeoPixel Ring - 16 x 5050 RGB LED with Integrated Drivers

[NeoPixel Ring - 16 x 5050 RGB LED with Integrated Drivers](https://www.adafruit.com/product/1463)
Round and round and round they go! 16 ultra bright smart LED NeoPixels are arranged in a circle with 1.75" (44.5mm) outer diameter. The rings are 'chainable' - connect the output pin of one to the input pin of another. Use only one microcontroller pin to control as many as you can...

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

[Lithium Ion Polymer Battery - 3.7v 150mAh](https://www.adafruit.com/product/1317)
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 150mAh for a total of about 0.6 Wh. If you need a larger battery, <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/1317)
[Related Guides to the Product](https://learn.adafruit.com/products/1317/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...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1063)
[Related Guides to the Product](https://learn.adafruit.com/products/1063/guides)
### Adafruit Micro Lipo - USB LiIon/LiPoly charger

[Adafruit Micro Lipo - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1304)
Oh so adorable, this is the tiniest little lipo charger, so handy you can keep it any project box! Its also easy to use. Simply plug in the gold plated contacts into any USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There are...

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

## Related Guides

- [Neopixel Jewel 10 Minute Necklace](https://learn.adafruit.com/10-minute-neopixel-necklace.md)
- [Multi-tasking the Arduino - Part 3](https://learn.adafruit.com/multi-tasking-the-arduino-part-3.md)
- [Glowing Scale Armor](https://learn.adafruit.com/glowing-scale-armor.md)
- [2014 Halloween 3D Printed Projects Roundup](https://learn.adafruit.com/2014-halloween-3d-printed-projects-roundup.md)
- [Capacitive Touch with Conductive Fabric & Flora](https://learn.adafruit.com/capacitive-touch-with-conductive-fabric-and-flora.md)
- [FFT: Fun with Fourier Transforms](https://learn.adafruit.com/fft-fun-with-fourier-transforms.md)
- [Glowing Skullcandy Headphones Mod](https://learn.adafruit.com/glowing-skullcandy-headphones-mod.md)
- [3D Printed Wireless MIDI Controller Guitar](https://learn.adafruit.com/ez-key-wireless-midi-controller-guitar.md)
- [3D Printed LED Microphone Flag](https://learn.adafruit.com/3d-printed-led-microphone-flag.md)
- [AdaBox 014](https://learn.adafruit.com/adabox014.md)
- [Flora Brake Light Backpack](https://learn.adafruit.com/flora-brakelight-backpack.md)
- [Electronic Demon Costume](https://learn.adafruit.com/electronic-demon-costume.md)
- [Using NeoPixels with Netduino Plus 2](https://learn.adafruit.com/using-neopixels-with-netduino.md)
- [EEG Costume Cap](https://learn.adafruit.com/eeg-costume-cap.md)
- [Bluetooth Remote Control for the Lego Droid Developer Kit](https://learn.adafruit.com/bluetooth-remote-for-lego-droid.md)
