# Circuit Playground Express Perk-up Ears

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/059/565/medium800thumb/wearables_hires-demo.jpg?1534955627)

This project uses the on-board microphone of the Circuit Playground Express's to trigger a pair of servo actuated costume ears to perk up when there is a loud noise. The ears are mounted on a hair band and the whole thing is completely self-contained.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/059/488/medium800thumb/wearables_dave-hold-demo.jpg?1534861669)

## Parts
This project uses a Circuit Playground Express, 2 servos, and a LiPo battery. Any size battery can be used, but the 1200 mAh model is a good balance between size and lifespan.

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### Micro servo

[Micro servo](https://www.adafruit.com/product/169)
Tiny little servo can rotate approximately 180 degrees (90 in each direction) and works just like the standard kinds you're used to but _smaller_. You can use any servo code, hardware, or library to control these servos. Good for beginners who want to make stuff move without...

In Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
![Micro servo with three pin cable](https://cdn-shop.adafruit.com/640x480/169-06.jpg)

### Lithium Ion Polymer Battery - 3.7v 1200mAh

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

Out of Stock
[Buy Now](https://www.adafruit.com/product/258)
[Related Guides to the Product](https://learn.adafruit.com/products/258/guides)
![Lithium Ion Polymer Battery 3.7v 1200mAh with JST 2-PH connector](https://cdn-shop.adafruit.com/640x480/258-02.jpg)

### Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces](https://www.adafruit.com/product/3448)
When working&nbsp;with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These compact jumper cables have a premium male header on one end and a grippy mini alligator clip on the...

In Stock
[Buy Now](https://www.adafruit.com/product/3448)
[Related Guides to the Product](https://learn.adafruit.com/products/3448/guides)
![Group of Small Alligator Clip to Male Jumper Wires](https://cdn-shop.adafruit.com/640x480/3448-00.jpg)

## Supplies

- Headband
- Construction paper
- Corrugated cardboard
- Hot glue and glue gun
- 2 rubber bands of an appropriate size
- Felt, faux fur, or fabric as desired to cover the ears
- Jumper wire with male pins if you want to solder to the CPX for a more robust connection
- flexible/stranded wire to use as an actuator
- 4 pieces of stiff wire (long male header pins work well) and wire to mechanically connect the servo&nbsp;

# Circuit Playground Express Perk-up Ears

## Wiring

The diagram below shows alligator clip wires being used to connect the servos, and this is fine for prototyping. But if you want things to be more robust some solder is probably going to be involved. You can cut male jumpers just long enough to reach the required pads on the Circuit Playground Express, coming together at the servo plug and solder them in place.&nbsp; For something even more permanent, you can trim the servo cables and solder them directly onto the Circuit Playground Express.

![](https://cdn-learn.adafruit.com/assets/assets/000/059/371/medium800/circuitpython_sound_ears.png?1534544919)

# Circuit Playground Express Perk-up Ears

## Construction

## Designing the ears

The first step is to make some ears from cardboard. You can experiment with shapes using construction paper. It's thin enough to be easy to work with, and still stiff enough to keep it's shape when folded. Once you have a design you like, it can be a template for markign the design on the corrugated cardboard.

![](https://cdn-learn.adafruit.com/assets/assets/000/059/374/medium800/circuitpython_2018-08-16_14-56-39-0400.jpg?1534549112)

In this case the square edges are 4cm long. The tip of the ear is 1 cm (3/8") wide, with 1.5 cm (5/8") on either side..

The construction paper prototype can be used as a template to mark out the design on cardboard. Mark them out with the corrugations running from the tip down the length of the piece with the two wings to the sides.&nbsp;

&nbsp;

The dotted lines are cut part way though, leaving the bottom outside layer. These are the fold lines.

![circuitpython_2018-08-16_16-34-56-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/376/medium640/circuitpython_2018-08-16_16-34-56-0400.jpg?1534553690)

![circuitpython_2018-08-16_16-42-47-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/378/medium640/circuitpython_2018-08-16_16-42-47-0400.jpg?1534554165)

![circuitpython_2018-08-16_16-42-57-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/379/medium640/circuitpython_2018-08-16_16-42-57-0400.jpg?1534554336)

![circuitpython_2018-08-16_16-43-28-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/380/medium640/circuitpython_2018-08-16_16-43-28-0400.jpg?1534554745)

## Aside: Reinforced corner joints
Folding the ear results in the bottom and sides meeting along the edges of the cuts. That means there's nothing to glue to. Although hotglue provides some structure itself, it's nice to have a bit more support for the joint. You can do this by cutting a matchstick shaped piece of cardboard to glue inside the corner. That lets each surface (the bottom and side in this case) be glued to this support.

&nbsp;

All three concave corners can benefit from a bead of hot glue to enhance the bond as well as provide additional structural support. Allow each bead to cool before adding the next or the heat may cause the entire joint to come apart.

![circuitpython_2018-08-17_22-10-45-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/389/medium640/circuitpython_2018-08-17_22-10-45-0400.jpg?1534597556)

![circuitpython_2018-08-17_22-11-27-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/390/medium640/circuitpython_2018-08-17_22-11-27-0400.jpg?1534598380)

![circuitpython_2018-08-17_22-15-35-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/391/medium640/circuitpython_2018-08-17_22-15-35-0400.jpg?1534598636)

![circuitpython_2018-08-17_22-16-20-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/392/medium640/circuitpython_2018-08-17_22-16-20-0400.jpg?1534598773)

![circuitpython_2018-08-18_09-03-57-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/393/medium640/circuitpython_2018-08-18_09-03-57-0400.jpg?1534598903)

![circuitpython_2018-08-18_10-28-24-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/398/medium640/circuitpython_2018-08-18_10-28-24-0400.jpg?1534602639)

The first step is to fold and glue the ears. You can use the method outlined above.

&nbsp;

Glue a small piece of plastic straw to the middle of the base of the flap to be a guide for the actuating wire.

&nbsp;

Next glue a servo to the back of each ear as shown: as far down and to the left as possible while still not protruding past the bottom or side of the ear. Consider peeling the foil label from the side of the servo being glued to the ear so that it won't later come off on its own.

&nbsp;

Poke a small hole near the end of the flap and place a rivet in it. Put the plate on the rivet, but only to the first position. You'll tighten it later. Make a similar hole near the middle of the back of the base.

&nbsp;

Place a rubber band around the flap rivet as shown. Use a rubber band that is taunt when the flap is extended and has enough strength to pull the flap back when it is released. Poke the other end of the rubber band through the hole in the base so that 2 mm (1/8") sticks through, then push the rivet through it from the top. Place the plate on the rivet and push it on to the second notch.

![circuitpython_2018-08-16_17-20-55-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/399/medium640/circuitpython_2018-08-16_17-20-55-0400.jpg?1534613451)

![circuitpython_2018-08-16_17-48-46-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/400/medium640/circuitpython_2018-08-16_17-48-46-0400.jpg?1534613746)

![circuitpython_2018-08-16_18-01-27-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/401/medium640/circuitpython_2018-08-16_18-01-27-0400.jpg?1534615890)

![circuitpython_2018-08-16_18-04-06-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/402/medium640/circuitpython_2018-08-16_18-04-06-0400.jpg?1534616270)

![circuitpython_2018-08-17_10-25-39-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/403/medium640/circuitpython_2018-08-17_10-25-39-0400.jpg?1534616412)

## Connecting the servos
Connect the servos to a board and set them to 0 degrees.&nbsp; Put a "half" horn (see the photos to the left) onto the shaft so that it faces up.

&nbsp;

Next you need to link the horn to the ear flap.&nbsp; You can use a short piece of wire looped around the rivet at the end of the flap and through the straw guide. The ends can be soldered to a small hook made from a pin from a male header strip bent around the tip of needle-nosed pliers.

&nbsp;

To connect the hook to the servo horn, make a loop from another, longer header pin and place it through the outermost hole in the horn. Squeeze the loop closed.&nbsp; Hook the hook on the wire through the loop on the horn and squeeze it closed. That will keep it from slipping out when the servo horn point up (and allowing the connecting wire to go slack).

&nbsp;

The goal is that when the servo is set to 90 degrees the flap is pulled vertical. When the servo goes back to zero degrees, the rubber band pulls the flap back down into the relaxed position.

![circuitpython_2018-08-17_10-29-32-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/405/medium640/circuitpython_2018-08-17_10-29-32-0400.jpg?1534617864)

![circuitpython_2018-08-17_10-30-07-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/406/medium640/circuitpython_2018-08-17_10-30-07-0400.jpg?1534617985)

![circuitpython_2018-08-17_10-30-21-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/407/medium640/circuitpython_2018-08-17_10-30-21-0400.jpg?1534618897)

![circuitpython_2018-08-17_10-25-59-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/414/medium640/circuitpython_2018-08-17_10-25-59-0400.jpg?1534620032)

![](https://cdn-learn.adafruit.com/assets/assets/000/059/475/medium800thumb/wearables_mechanism_demo.jpg?1534793955)

## Covering the mechanism
Now you have working ears. Let's make them look a bit better. You can use any sort of fabric to cover them, felt on the inside and fur on the back would be awesome, but here we just use some felt to keep it easy to see what's going on.

&nbsp;

Start by cutting an outside piece for each ear. The exact shape isn't overly important; it has to be big enough to accommodate the servo and the motion of the flap, but not so big as to completely obscure the overall ear shape. Secure the corners as shown to the flap rivet, and the front corners of the base.

&nbsp;

Cut a similar piece for the inside of the ear. It only has to allow for the flap movement.&nbsp; Tack the corners to the same points as the outside fabric, only on the inside of the ear. Then apply glue along the inside edges of the outside piece, and secure the edges of the inside piece. The final two photos show the result.

![circuitpython_2018-08-17_10-43-45-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/420/medium640/circuitpython_2018-08-17_10-43-45-0400.jpg?1534621532)

![circuitpython_2018-08-17_11-48-36-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/427/medium640/circuitpython_2018-08-17_11-48-36-0400.jpg?1534621863)

![circuitpython_2018-08-17_11-49-07-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/429/medium640/circuitpython_2018-08-17_11-49-07-0400.jpg?1534622109)

![circuitpython_2018-08-17_13-00-02-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/430/medium640/circuitpython_2018-08-17_13-00-02-0400.jpg?1534622221)

![circuitpython_2018-08-17_13-04-35-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/431/medium640/circuitpython_2018-08-17_13-04-35-0400.jpg?1534622854)

![circuitpython_2018-08-17_13-05-13-0400.jpg](https://cdn-learn.adafruit.com/assets/assets/000/059/432/medium640/circuitpython_2018-08-17_13-05-13-0400.jpg?1534623032)

## Final assembly

All that's left is to mount the two ears, the Circuit Playground Express, and the battery to a headband. Hot glue works well with the ears, while double sided tape will work for the board and battery.

![](https://cdn-learn.adafruit.com/assets/assets/000/059/469/medium800/wearables_2018-08-20_12-29-35-0400.jpg?1534782694)

# Circuit Playground Express Perk-up Ears

## Code

![](https://cdn-learn.adafruit.com/assets/assets/000/059/387/medium800/robotics___cnc_circuitpython_blinka-small.png?1534561295)

We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries,&nbsp;[there is a full getting started guide here](https://learn.adafruit.com/welcome-to-circuitpython).

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython.&nbsp;[You can learn about Mu and its installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

The code is based on [this guide on CircuitPython audio for the Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express/playground-sound-meter).

A `PDMIn` object is created to read sound levels from the mic, which are stored in the `array` named `samples`. Those samples are then combined using root-mean-square to get a measure of the amount of energy in the sound (which corresponds to the overall volume) and mapped onto a logarithmic scale from 0 to 10. If that results in a value greater than or equal to the trigger threshold (defined by `THRESHOLD`) the ears perk up. If it's less than `THRESHOLD`, the ears relax.

Beyond the above, the code only perks up or relaxes the ears the first time the sound is louder or quieter than the threshold. The state variable `ears_up` tracks the state of the ears (`True` represents perked up). So the ears will perk up only when the sound is loud enough and the ears are relaxed. If the sound is quiet and the ears are perked up, they will relax.

Why the extra code? To manage a cool off period of a second after the state of the ears changes. The code sleeps for that time and doesn't check the sound. This helps avoid the ears fluttering when the sound level is around the threshold. It also keeps the ears perked up for a second which enhances the effect.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Sound_Reactive_Ears/code.py

# Circuit Playground Express Perk-up Ears

## Wrapup

This guide describes a project to build a set of costume ears that will perk up when there's a loud noise. The final construction was quite basic, but could be incorporated into a more elaborate headpiece of, say, a werewolf costume.

It could also be the basis of a steampunk gadget that reacts to sound.

Have fun!


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

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

[Micro servo](https://www.adafruit.com/product/169)
Tiny little servo can rotate approximately 180 degrees (90 in each direction) and works just like the standard kinds you're used to but _smaller_. You can use any servo code, hardware, or library to control these servos. Good for beginners who want to make stuff move without...

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

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

Out of Stock
[Buy Now](https://www.adafruit.com/product/258)
[Related Guides to the Product](https://learn.adafruit.com/products/258/guides)
### Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces](https://www.adafruit.com/product/3448)
When working&nbsp;with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These compact jumper cables have a premium male header on one end and a grippy mini alligator clip on the...

In Stock
[Buy Now](https://www.adafruit.com/product/3448)
[Related Guides to the Product](https://learn.adafruit.com/products/3448/guides)
### Plastic Pop Rivets for Cardboard Crafts (20-pack)

[Plastic Pop Rivets for Cardboard Crafts (20-pack)](https://www.adafruit.com/product/3822)
Enter the world of cardboard construction and build playful robot friends!&nbsp;

Instead of slapping on tape or waiting for your hot glue to warm up, you can use these **Large Plastic Rivets**! So easy to install. Just poke them through the cardboard and fasten with the back...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/3822)
[Related Guides to the Product](https://learn.adafruit.com/products/3822/guides)
### Circuit Playground Express - Base Kit

[Circuit Playground Express - Base Kit](https://www.adafruit.com/product/3517)
It's the **Circuit Playground Express Base Kit!** &nbsp;It provides&nbsp;the few things you'll need to get started with the new [Circuit Playground Express](https://www.adafruit.com/product/3333).&nbsp;This version of Circuit Playground is super powered, and will...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3517)
[Related Guides to the Product](https://learn.adafruit.com/products/3517/guides)
### Circuit Playground Express Advanced Pack

[Circuit Playground Express Advanced Pack](https://www.adafruit.com/product/2769)
 **Circuit Playground Express** &nbsp;is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to program....

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

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [3D Printed Heel Clips](https://learn.adafruit.com/3d-printed-heel-clips.md)
- [Crickit Collapsible House with MakeCode](https://learn.adafruit.com/collapsible-house.md)
- [Make It Plot](https://learn.adafruit.com/make-it-graph-plot.md)
- [Sparky the Blue Smoke Monster Automaton](https://learn.adafruit.com/sparky-automaton.md)
- [Circuit Playground or Hallowing Jack-o'-Lantern](https://learn.adafruit.com/circuit-playground-jack-o-lantern.md)
- [Musical Walking Stick with Circuit Playground](https://learn.adafruit.com/musical-cane-walking-stick.md)
- [FruitBox Sequencer: Musically Delicious Step Pattern Generator ](https://learn.adafruit.com/circuitpython-fruitbox-sequencer-musically-delicious-step-pattern-generator.md)
- [Light Paintbrush with Circuit Playground](https://learn.adafruit.com/lightpaint-cplay.md)
- [CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials.md)
- [Circuit Playground Express TV Zapper](https://learn.adafruit.com/circuitpython-tv-zapper-with-circuit-playground-express.md)
- [Infrared Hand Gesture Robot Control Glove](https://learn.adafruit.com/cpx-ir-infrared-hand-gesture-robot-control-glove.md)
- [The Scream: Interactive Screaming Painting](https://learn.adafruit.com/the-scream-munch-screaming-interactive-scream-painting.md)
- [Rainbow Bottle Lamp with Fairy Lights](https://learn.adafruit.com/glowing-bottle-lamp.md)
- [Affordable HAL 9000 Replica](https://learn.adafruit.com/hal-9000-replica.md)
- [Make It Bubble](https://learn.adafruit.com/make-it-bubble.md)
