# Chatty Light-Up Circuit Playground Express Mask

## Overview

https://youtu.be/BK8HM8yILMs

Most of the time, we wear masks to help us stay safe. But sometimes, it's fun to add a little life to your facewear. This mask uses an Adafruit Circuit Playground Express board to flash a shiny smile whenever you talk, using its built-in sound sensor and easy-to-learn Microsoft MakeCode programming!

This mask itself is simple to sew by hand or on a machine and comfortable to wear. It's got two layers of fabric with a pouch that can hold a filter -- or your CPX.&nbsp;

It's a great project for kids (or anyone) who are just learning to sew _and_ learning to code!

## Parts List -- Electronics

About all you need for this project is a Circuit Playground Express programmable microcontoller board, a USB cable to transfer the programming from your computer to the board, and a AAA battery holder to make it portable. These are all contained in the CPX Base Kit, or you can buy what you need separately. You'll also need extension wires (one for a child, or chain two together for an adult) that can connect the board in your mask with the battery pack in your pocket.

### 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)

### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
![Front angled shot of 3 x AAA battery holder with on-off switch and 2-pin JST PH connector.](https://cdn-shop.adafruit.com/640x480/727-07.jpg)

### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

In Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
![USB cable - USB A to Micro-B - 3 foot long](https://cdn-shop.adafruit.com/640x480/592-01.jpg)

### JST-PH Battery Extension Cable - 500mm

[JST-PH Battery Extension Cable - 500mm](https://www.adafruit.com/product/1131)
By popular demand, we now have a handy extension cord for all of our JST PH-terminated battery packs (such as our LiIon/LiPoly and 3xAAA holders). One end has a JST-PH compatible socket, and the other end has a matching plug. Between the two, 500mm of color coded wire. Handy for wearable...

In Stock
[Buy Now](https://www.adafruit.com/product/1131)
[Related Guides to the Product](https://learn.adafruit.com/products/1131/guides)
![Front shot of JST-PH Battery Extension Cable.](https://cdn-shop.adafruit.com/640x480/1131-00.jpg)

### 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)
![Rectangular case for Circuit Playground Express - Base Kit.](https://cdn-shop.adafruit.com/640x480/3517-04.jpg)

## Materials List -- Household and Crafts Supplies

Other supplies you will need include:

- 8 inch by 16 inch piece of tightly-woven cotton fabric ("quilting fabric"), preferably in a dark color
- two (2) pieces of t-shirt yarn or other cord, about 28 inches long

Optional:

- 4 inch long piece of twist-tie or other wire
- two (2) plastic beads with a large opening ("pony beads")
- pair of peel-and-stick Velcro dots
- disposible, non-woven filter layer, such as a coffee filter, one ply of paper towel, or waffle-pattern conference tote bag material.

# Chatty Light-Up Circuit Playground Express Mask

## Make the Mask

![](https://cdn-learn.adafruit.com/assets/assets/000/092/654/medium800/wearables_IMG_9307.jpg?1593568827)

The mask in this project is based on the "Imara mask" designed by [Airigami](http://www.airigami.com/) artist Kelly Cheatle (original [printable instructions here](http://antisocialartshow.org/wp-content/uploads/2020/04/imara.pdf)). It's a two-layer mask with a pouch to hold a disposable filter (made from a piece of non-woven material, such as a single ply of paper towel) and a casing or tunnel where you can insert a wire to make it fit better over the bridge of your nose. It also offers comfy ties that can go behind your head as well as around your ears.

All you need to make it is a rectangle of fabric (8 inches by 16 inches) and two cords made from t-shirt yarn (long narrow strips of t-shirt material pulled until they curl up).

The mask is sized for an adult, but easy to adjust by scrunching up the sides. The width when finished is 7 1/2 inches, and should fit snugly against your cheeks. If you need to make the mask smaller (or larger), just size the rectangle down (or up).

One change from the original pattern: You'll need to add a 1/2-inch gap in the stitching along the bottom to run a wire from the battery pack in your pocket to the Circuit Playground Express board inside the mask.

Here's what to do:

Warning: 

## Sew the Top and Sides
Fold down 3/4 inch from the top of the piece of fabric and press with an iron or your fingers. Fold up 1/2 inch from the bottom the same way.

To make a casing or tunnel that can hold a piece of wire to bend over your nose, stitch 1/4 inch from the top fold with a machine or by hand.

Turn when you reach the end, stitch down 1/4 inch, then go back to the first side -- stopping 2 inches before the end.

Fold the piece of fabric in half, wrong side out, and sew the raw sides together 1/2 inch from the edge.

&nbsp;

![wearables_02-Iron.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/672/medium640/wearables_02-Iron.jpg?1593632134)

![wearables_03-SewingMachine.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/674/medium640/wearables_03-SewingMachine.jpg?1593632191)

![wearables_07-StitchesTop.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/675/medium640/wearables_07-StitchesTop.jpg?1593632281)

![wearables_8-StitchesSide.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/676/medium640/wearables_8-StitchesSide.jpg?1593632301)

## Sew Side Casings to Hold the Cords
Turn the mask right side out. You can press the seam flat if you wish.

Take one of the t-shirt yarn cords and insert it into the mask. If you're machine sewing, pin the cord along one side of the mask.

Stitch a casing for the cord, about 5/8 inch from the edge, being careful not to catch the t-shirt yarn in your stitches.

Stitch the bottom of the mask closed -- stopping a little more than an inch from the side to leave an opening for the battery pack wire.

Insert the other cord along the other side of the mask. Stitch the casing to hold it closed the same way as you did the first.

![wearables_9-RightsideOut.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/677/medium640/wearables_9-RightsideOut.jpg?1593632671)

![wearables_10-YarnCasing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/678/medium640/wearables_10-YarnCasing.jpg?1593632691)

![wearables_12-BottomSeam.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/680/medium640/wearables_12-BottomSeam.jpg?1593632759)

![wearables_13-AllSeams.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/681/medium640/wearables_13-AllSeams.jpg?1593632789)

## Add Nose Wire and Finish the Cords
If you want to add a wire to make the mask fit better over your nose, cut a piece of wire about 4 inches long. With pliers, bend the tips over to hide the sharp ends.

Insert the wire into the opening you left in the top seam of the mask and center it. Wear the mask with the wire side facing out.

To finish the ends of the cords, you can simple knot them. To wear the mask, tie the top ends together behind your head and the bottom ends together behind your neck. You can also tie the ends of one side together to make ear loops.

Another way to finish the cords is to use beads with a large hole, like pony beads, as cord locks.

First, decide whether you want to wear the cords behind your head or as ear loops.

Then take the ends you want to connect and pinch the ends together. Use something with a blunt point to help you push both ends through the bead at the same time. Here I used a bamboo skewer with the pointy tip snipped off.&nbsp;

Then cut off any extra if you wish and knot each end as before.

![wearables_14-InsertWire.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/682/medium640/wearables_14-InsertWire.jpg?1593633143)

![wearables_15-KnotEnds.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/683/medium640/wearables_15-KnotEnds.jpg?1593633163)

![wearables_16-Beads.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/684/medium640/wearables_16-Beads.jpg?1593633193)

![wearables_17-Finished.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/685/medium640/wearables_17-Finished.jpg?1593633233)

Info: 

# Chatty Light-Up Circuit Playground Express Mask

## Program the CPX with MakeCode!

![](https://cdn-learn.adafruit.com/assets/assets/000/092/695/medium800/wearables_MakeCode-OnLoud.jpg?1593636457)

To make the mask light up when you talk, you'll be programming the Circuit Playground Express using Microsoft MakeCode. It's really easy to learn and fun to play around with! You can use it online at the [Adafruit MakeCode site](https://makecode.adafruit.com/), or offline with the Windows 10 app on your computer. If you've never used MakeCode before, there's [a guide to getting started here](https://learn.adafruit.com/makecode/what-is-makecode).

First, you'll figure out how to program the ring of lights on the CPX to look like a mouth opening, closing, and smiling. Then you'll add code to trigger the lights using the sound sensor/microphone built into the board.

The instructions below show two ways to trigger the lights respond to your voice. One uses a pre-built code block called `on loud`. You can check out the completed code of that version by clicking the button here.

[Talking Mask "On Loud"](https://makecode.com/_LcXMJ7UAmXKg)
If you need to fine-tune your code to make your talking mask work better, go on to the steps that show you how to adjust the sound sensor to respond to the volume that you set using the `sound level` block. This version was adapted from the [Sound Activated Shark Mask learning guide](https://learn.adafruit.com/sound-activated-shark-mask/makecode). The button below takes you to sample code using that method:

[Talking Mask "Sound Level"](https://makecode.com/_RLiWKiMw6Wye)
![](https://cdn-learn.adafruit.com/assets/assets/000/092/731/medium800/wearables_105-CPX_Smile.jpg?1593719597)

## Program the Lights

The first step is to make the lights flash in a pattern that looks like a mouth talking. To do this, imagine turning the Circuit Playground Express board simulation on the screen sideways, so that the lights go across the top and the bottom.

When all the lights are lit, the "mouth" is open.

With just the bottom row lit up, the lights form a little smile.

The pattern of lights used in the example shown here is:

- The open mouth flashes on and off twice.
- The smile flashes on for a moment, then turns off.

You'll be building this part of the code using the `show ring` block from the **LIGHT** category of blocks in the menu column. Change the colors of the ring of lights by clicking on a color in the center of the diagram and then on the lights you want to change.

To test your program, insert the code inside the `forever` block that's already in the workspace whenever you open a new project. Here's how:

### Program the Open Mouth

First, drag a `show ring` block into the workspace and insert it into the forever block. Change all the lights to white.

Then right-click on the `show ring` block to duplicate it, or just drag a new one over from the menu and place it under the first one. Click on the gray space in the middle of the ring, then click on every light to turn them all off.

The lights on the simulated board should start to flash on and off continually.

![wearables_101LightsFlash.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/721/medium640/wearables_101LightsFlash.jpg?1593716219)

### Program the "Smile"

Next, take another `show ring` block, attach it underneath the first two blocks, and turn just the lights on one side to white. (Which side depends on where you put the opening for the battery pack wire on your mask -- the JST cable plugs into the port shown at the bottom of the simulated board.)

Duplicate the block that turns all the lights off and put it at the end of the stack.

![wearables_104-Smile.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/725/medium640/wearables_104-Smile.jpg?1593718597)

### Add Repeats and Pauses

To create a pattern of flashes where the whole ring flashes twice,&nbsp; drag a `repeat` block from LOOPS and place it around the first two `show ring` blocks. Change the number of repeats to 2.

Then, to adjust the timing, go back to LOOPS and drag a `pause` block into the stack _after_ the repeat. Change the timing to whatever you like -- in this example, 300 milliseconds (about a third of a second). Add another `pause` block after the third `show ring` block. This one is set to 700 ms in the example.

![wearables_104-Repeat.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/726/medium640/wearables_104-Repeat.jpg?1593718636)

![wearables_104-Pause.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/727/medium640/wearables_104-Pause.jpg?1593718651)

## Program the Sound Sensor/Microphone

Now it's time to add the sound sensor to trigger the pattern of lights!

### Using the `on loud` block

From the **INPUT** category on the block menu, drag and drop an `on loud` block in the workspace.

To move the stack of code from the `forever` block, grab the top of the `repeat` block. The entire stack will come with it. Drag it inside the `on loud` block.

Look at the simulation of the board. Near the bottom left corner, a small round sound level indicator has appeared. It's at the midway point, which 128. (The highest it can go is 255.)

You can grab and move the indicator up and down, like a window shade. When that indicator hits about 191, the `on loud` command triggers the lights to flash.

![wearables_106-On_Loud.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/732/medium640/wearables_106-On_Loud.jpg?1593719867)

![wearables_106-On_Loud2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/735/medium640/wearables_106-On_Loud2.jpg?1593721504)

![wearables_106-Sound_Gauge.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/736/medium640/wearables_106-Sound_Gauge.jpg?1593721536)

![wearables_106-Sound_GaugeUp.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/737/medium640/wearables_106-Sound_GaugeUp.jpg?1593721552)

Follow the [instructions on the MakeCode guide to download your program](https://learn.adafruit.com/makecode/downloading-and-flashing) to your CPX board.

Then test to see whether this will work for your mask by putting the CPX board near your mouth. Say something in your normal speaking voice.

If the lights don't turn on, go on to the next section and try creating some code that lets you adjust the sound sensor.

### Using the `sound level` Block

From the **LOOPS** category on the block menu, drag and drop a `while` block in the workspace. Insert it _inside_ the `forever` loop and _around_ the rest of the stack of code, starting with the `repeat` loop.

Next, from the **LOGIC** category, drag and drop a pointy-tipped `0 = 0` comparison block. Change the "equal" sign to a "greater or equal to" sign. (It looks like ≤.) In the second oval, type 140 over the 0. Then drag the block over the pointy-tipped "true" space on the `while` block and let it click into place.

Now go to the INPUT category and scroll down until you see some oval-shaped blocks. Drag the `sound level` block into the workspace. Drop it over the first oval on the comparison block.

![wearables_107a-While.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/743/medium640/wearables_107a-While.jpg?1593723624)

![wearables_107b-Greater_Than.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/744/medium640/wearables_107b-Greater_Than.jpg?1593723635)

![wearables_107c-SoundLevel2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/745/medium640/wearables_107c-SoundLevel2.jpg?1593723665)

![wearables_107d-Sound_Level_Done.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/746/medium640/wearables_107d-Sound_Level_Done.jpg?1593723694)

That's it! You've set the sound sensor to trigger your code when the sound level gets to 140 or above. Again, follow the [instructions on the MakeCode guide to download your program](https://learn.adafruit.com/makecode/downloading-and-flashing) to your CPX board.

Test out this setting the same way you did before and adjust it lower or higher to work with your mask.

When everything's working, go to the last page to see how to insert the electronics into your mask.

# Chatty Light-Up Circuit Playground Express Mask

## Add the Electronics

![](https://cdn-learn.adafruit.com/assets/assets/000/092/687/medium800/wearables_18-CPXPouch.jpg?1593635054)

Once your mask is done and the Circuit Playground Express is programmed, you can add all the electronics to the mask!

The CPX board slips right into the filter pouch. You can carry the AAA battery pack in a pocket, or use the belt clip to attach it to a piece of clothing.

Make sure it won't snag on anything as you walk around. You may want to thread the extension wire down into your collar and under your shirt.

Danger: 

Attach the JST extension wire to the battery pack. If it's not long enough to reach from the mask to wherever you are going to carry the battery, attach a second extension wire to the first.

Slide the end of the extension wire through the opening you left in the bottom seam. Thread it into the pouch and connect it to the CPX board.

To test it out, position the CPX in the middle of the mask, with the wire pointed towards the side its threaded through. In other words, the board will be sideways, with the lights positioned at the top and bottom.

Try on the mask and adjust the board so it sits over your mouth.

Then turn on the batteries and say something to see how it works!

![wearables_18-BatteryPack.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/690/medium640/wearables_18-BatteryPack.jpg?1593635497)

![wearables_20-InsertWire.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/691/medium640/wearables_20-InsertWire.jpg?1593635660)

![wearables_23-CPX_close-up.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/693/medium640/wearables_23-CPX_close-up.jpg?1593636264)

![wearables_22-FinishedWornMask2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/092/694/medium640/wearables_22-FinishedWornMask2.jpg?1593636361)

Info: 


## 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)
### 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)
### 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip

[3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip](https://www.adafruit.com/product/3286)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries, plus it has&nbsp;a nifty&nbsp;on-off...

In Stock
[Buy Now](https://www.adafruit.com/product/3286)
[Related Guides to the Product](https://learn.adafruit.com/products/3286/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

In Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
### JST-PH Battery Extension Cable - 500mm

[JST-PH Battery Extension Cable - 500mm](https://www.adafruit.com/product/1131)
By popular demand, we now have a handy extension cord for all of our JST PH-terminated battery packs (such as our LiIon/LiPoly and 3xAAA holders). One end has a JST-PH compatible socket, and the other end has a matching plug. Between the two, 500mm of color coded wire. Handy for wearable...

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

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Circuit Playground Express Sugar Glider](https://learn.adafruit.com/cpx-sugar-glider.md)
- [CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials.md)
- [Make It Shake, Rattle, and Roll: Accelerometer Use](https://learn.adafruit.com/make-it-shake-rattle-and-roll.md)
- [LEGO Head Lamp with Audio](https://learn.adafruit.com/lego-head-lamp-with-audio.md)
- [Sensors in MakeCode](https://learn.adafruit.com/sensors-in-makecode.md)
- [The Tilt Trumpet](https://learn.adafruit.com/the-tilt-trumpet.md)
- [CircuitPython Hardware: SD Cards](https://learn.adafruit.com/micropython-hardware-sd-cards.md)
- [Crickit Dancing Marionette Kit](https://learn.adafruit.com/universal-marionette-with-crickit.md)
- [Circuit Playground Express Perk-up Ears](https://learn.adafruit.com/perk-up-ears.md)
- [NYE Circuit Playground Drop](https://learn.adafruit.com/nye-circuit-playground-drop.md)
- [New Year Countdown Clock with Circuit Playground Express](https://learn.adafruit.com/new-year-countdown-clock-with-circuit-playground-express.md)
- [Edit CircuitPython Code on iOS with Runestone](https://learn.adafruit.com/editing-circuitpython-on-ios-with-runestone.md)
- [Using Servos With CircuitPython and Arduino](https://learn.adafruit.com/using-servos-with-circuitpython.md)
- [How to Use Video Greenscreen in MakeCode](https://learn.adafruit.com/how-to-use-video-greenscreen-in-makecode.md)
- [Circuit Playground Express Head-Tilt Ears](https://learn.adafruit.com/circuit-playground-express-head-tilt-ears.md)
