# Polka Dot Electro-Swing Dress with NeoPixels

## Overview

https://youtu.be/t-49IvmEL7M

Put on your dancing shoes and get ready to light up the joint! This project transforms a classic black-and-white polka-dot swing dress into a motion-reactive wearable filled with colorful animated light.

Each polka dot conceals a lightweight, individually addressable NeoPixel on a strand. When the dress is still, the lights give a slow twinkle to the skirt. When you perform an energetic twirl or jump, glowing flares race upward across the fabric, flickering and lighting you up with energy and sparkle.

This is an intermediate wearable project. You’ll need some sewing experience, along with a little patience while laying out and connecting the lights. We've provided sample code in CircuitPython, and you can select your colors and animation speeds with easy code variable modifications.

The finished dress is comfortable enough to dance in and dramatic enough for performances, parties, or any night when ordinary polka dots simply won’t do. Choose a dress and color palette that match your style, then get ready to jump, jive, and light up the night.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/907/medium800/led_pixels_polkadots_window.jpeg?1784651091)

## Parts
## Selecting your Dress

Shop around for a dress you love that has light colored polka dots. [I used this one from RetroSwing](https://www.retro-stage.com/products/1950s-halter-polka-dot-print-swing-dress). It might be a good idea to get the dress before ordering pixels, so you know which spacing will work best with your fabric.

In the product photo it looks like the dots get bigger near the hemline but in reality they're all the same size and spacing. Also, they did a pretty good job of matching the pattern along the seamline, which turned out to be important for layout.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/910/medium640/led_pixels_1950s_Halter_Polka_Dot_Print_Swing_Dress___Retro_Stage-2.jpg?1784652361)

The dots on this dress are about 1.5-1.75" (38-45.5mm) apart, on the diagonal, which is perfect for the 2" (5mm) pixels. Adafruit also carries [seed pixels with 4" (10mm) spacing](https://www.adafruit.com/product/6026) in case that works better with your dress.

Featured
### Adafruit NeoPixel Pebble / Seed LED Strand - 300 LEDs - 2" Pitch

[Adafruit NeoPixel Pebble / Seed LED Strand - 300 LEDs - 2" Pitch](https://www.adafruit.com/product/6023)
We have all&nbsp;sorts of LED strips for a wide range of needs.&nbsp;[_Chonky_](https://www.adafruit.com/product/3869)&nbsp;strips? We got those!&nbsp;[Strips with alligator...](https://www.adafruit.com/?q=neopixel%20alligator%20clips%20stripping%20wires)

In Stock
[Buy Now](https://www.adafruit.com/product/6023)
[Related Guides to the Product](https://learn.adafruit.com/products/6023/guides)
![Pebble strand LED strips lit up yellow-pink and blue.](https://cdn-shop.adafruit.com/640x480/6023-04.jpg)

The Seed Pixel strand comes pre-soldered with these 3-pin JST connectors. If you're planning to use this strand for more than one project (and we're only using a small section of it so you'll have a lot left), it's a good idea to get a few more.

Featured
### 3-pin JST SM Plug + Receptacle Cable Set

[3-pin JST SM Plug + Receptacle Cable Set](https://www.adafruit.com/product/1663)
These 3-wire cables are 163mm (6.4") long and come as a set. One cable has a JST SM type connector plug on the end. The other cable has a matching JST SM type receptacle connector. They are good for whenever you have 3 wires you want to be able to plug and unplug. We like the solid and...

In Stock
[Buy Now](https://www.adafruit.com/product/1663)
[Related Guides to the Product](https://learn.adafruit.com/products/1663/guides)
![Angled shot of 2 3-pin JST SM Plug + Receptacle Cable.](https://cdn-shop.adafruit.com/640x480/1663-00.jpg)

The animations run in CircuitPython on the Adafruit RP2040 Prop-Maker Feather. The board’s onboard accelerometer watches for sudden movement and triggers the light effect automatically—no buttons or remote controls required. The code is easy to customize with your own colors, brightness, motion sensitivity, and animation timing.&nbsp;

Featured
### Adafruit RP2040 Prop-Maker Feather with I2S Audio Amplifier

[Adafruit RP2040 Prop-Maker Feather with I2S Audio Amplifier](https://www.adafruit.com/product/5768)
The Adafruit Feather series gives you lots of options for a small, portable, rechargeable microcontroller board. By picking a feather and stacking on a FeatherWing you can create advanced projects quickly. One popular combo is our [Feather M4](https://www.adafruit.com/product/3857)...

In Stock
[Buy Now](https://www.adafruit.com/product/5768)
[Related Guides to the Product](https://learn.adafruit.com/products/5768/guides)
![Video of a white hand pressing a button to briefly turn an LED strip into white lights. Also wired up to the microcontroller are a servo motor and a speaker.](https://cdn-shop.adafruit.com/product-videos/640x480/5768-09.jpg)

Featured
### USB Type C Sync Data Cable with On-Off Switch - 28cm long

[USB Type C Sync Data Cable with On-Off Switch - 28cm long](https://www.adafruit.com/product/6268)
This **USB Type C Sync Data Cable with On/Off Switch** &nbsp;cable is great when you don't want to plug-and-unplug a device to turn it on and off. It's a true USB C to C cable, with power, data and power delivery (USB C PD)&nbsp;lines connected so it can be used for high...

Out of Stock
[Buy Now](https://www.adafruit.com/product/6268)
[Related Guides to the Product](https://learn.adafruit.com/products/6268/guides)
![Angled Shot of the USB C M/M 30cm data+power switch.](https://cdn-shop.adafruit.com/640x480/6268-01.jpg)

[USB Battery Pack](https://a.co/d/030Fc4Pg)

This little battery is my favorite for wearables. It's small and light and easy to use and recharge. Also you can charge your phone with it, if you're out at an event without your charger!

![](https://cdn-learn.adafruit.com/assets/assets/000/144/909/medium640/led_pixels_battery.jpg?1784651627)

## Additional Materials & Tools

- [Zots 3-d Glue Dots](https://www.amazon.com/dp/B0013JN2C0?ref=ppx_yo2ov_dt_b_fed_asin_title)
- [Lightweight Fusible Interfacing](https://www.amazon.com/Fusible-Interfacing-Non-Woven-Polyester-Single-Sided/dp/B0981C2LLY/ref=sr_1_4?crid=1L459MKR9K0HM&dib=eyJ2IjoiMSJ9.W5sJdDgWNrJ4Hc7NMKa3OepJ_qeMPIQ92mQ9XZPCW6hJppQXnslBEZzmipPm3VRr-kGhVLIeajVO8jcbBhANF89dWnguD073yDAxboidQYm2wDYA-O7XEXpLQVmVHu8XV545NInmwwPsYL6rio-1WE0u3O1i2BeQZbgGq1mZKpGb2CYoJqIKNqQ5FqJRay2nGS9Gi9TvnLeJ91hWjtq81kqZdZxc-AP-N_CCoi_CrOC7HUiZIAyGYTtdtRDsK8-zNIcl7_o1NPpX6AkbfXWxCOpYxzZxsI5xh9EFRMcOAMY.yRJFSvsYp3xihbtm93ZNfD3c4gxm7w9avBwz5DgUYAM&dib_tag=se&keywords=fusible%2Bfeatherweight%2Binterfacing%2Bblack&qid=1784652780&s=arts-crafts&sprefix=fusible%2Bfeatherweight%2Binterfacing%2Bbla%2Carts-crafts%2C432&sr=1-4&th=1)
- [1" Clear Heat Shrink Tubing](https://a.co/d/0iYjZkZe)
- A tiny flat head screwdriver: [we have a great set in the shop](https://www.adafruit.com/product/424)
- Wire strippers & cutters
- An iron & ironing board
- A thread ripper
- A sewing machine or needle & thread
- Extra fabric & velcro for a battery pocket

# Polka Dot Electro-Swing Dress with NeoPixels

## Wiring Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/144/911/medium800/led_pixels_wiring.png?1784653549)

The seed pixel strand attaches to the screw terminal as shown:&nbsp;

- +5v to +5v
- G to G
- DI to NEO

Plug your inline switch into the USB port on the board, and plug the battery into the other end of the switch.

# Polka Dot Electro-Swing Dress with NeoPixels

## CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython running on your board.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_feather_rp2040_prop_maker/)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/655/medium640/install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg?1618943202)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/865/medium800/adafruit_products_boot_reset.jpg?1686710555)

To enter the bootloader, hold down the **BOOT/**** BOOTSEL button**(highlighted in red above), and while continuing to hold it (don't let go!), press and release the**reset button**(highlighted in red or blue above).&nbsp;**Continue to hold the BOOT/BOOTSEL button until the RPI-RP2 drive appears!**

If the drive does not appear, release all the buttons, and then repeat the process above.

You can also start with your board unplugged from USB, press and hold the BOOTSEL button (highlighted in red above), continue to hold it while plugging it into USB, and wait for the drive to appear before releasing the button.

A lot of people end up using charge-only USB cables and it is very frustrating! **Make sure you have a USB cable you know is good for data sync.**

You will see a new disk drive appear called **RPI-RP2**.

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **RPI-RP2.**

![install_circuitpython_on_rp2040_RP2040_bootloader_drive.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/656/medium640/install_circuitpython_on_rp2040_RP2040_bootloader_drive.jpg?1618943666)

![install_circuitpython_on_rp2040_RP2040_drag_UF2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/657/medium640/install_circuitpython_on_rp2040_RP2040_drag_UF2.jpg?1618943674)

The **RPI-RP2** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it, you're done! :)

![install_circuitpython_on_rp2040_RP2040_CIRCUITPY.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/658/medium640/install_circuitpython_on_rp2040_RP2040_CIRCUITPY.jpg?1618943864)

## Safe Mode

You want to edit your **code.py** or modify the files on your **CIRCUITPY** drive, but find that you can't. Perhaps your board has gotten into a state where **CIRCUITPY** is read-only. You may have turned off the **CIRCUITPY** drive altogether. Whatever the reason, safe mode can help.

Safe mode in CircuitPython does not run any user code on startup, and disables auto-reload. This means a few things. First, safe mode _bypasses any code in_ **boot.py** (where you can set **CIRCUITPY** read-only or turn it off completely). Second, _it does not run the code in_ **code.py**. And finally, _it does not automatically soft-reload when data is written to the_ **CIRCUITPY** _drive_.

Therefore, whatever you may have done to put your board in a non-interactive state, safe mode gives you the opportunity to correct it without losing all of the data on the **CIRCUITPY** drive.

### Entering Safe Mode
To enter safe mode when using CircuitPython, plug in your board or hit reset (highlighted in red above). Immediately after the board starts up or resets, it waits 1000ms. On some boards, the onboard status LED (highlighted in green above) will blink yellow during that time. If you press reset during that 1000ms, the board will start up in safe mode. It can be difficult to react to the yellow LED, so you may want to think of it simply as a slow double click of the reset button. (Remember, a fast double click of reset enters the bootloader.)

### In Safe Mode

If you successfully enter safe mode on CircuitPython, the LED will intermittently blink yellow three times.

If you connect to the serial console, you'll find the following message.

```terminal
Auto-reload is off.
Running in safe mode! Not running saved code.

CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.
```

You can now edit the contents of the **CIRCUITPY** drive. Remember, _your code will not run until you press the reset button, or unplug and plug in your board, to get out of safe mode._

## Flash Resetting UF2

If your board ever gets into a really _weird_ state and CIRCUITPY doesn't show up as a disk drive after installing CircuitPython, try loading this 'nuke' UF2 to RPI-RP2. which will do a 'deep clean' on your Flash Memory. **You will lose all the files on the board** , but at least you'll be able to revive it! After loading this UF2, follow the steps above to re-install CircuitPython.

[Download flash erasing "nuke" UF2](https://cdn-learn.adafruit.com/assets/assets/000/101/659/original/flash_nuke.uf2?1618945856)
# Polka Dot Electro-Swing Dress with NeoPixels

## Test Code

This code will light all pixels connected to the NEO pin on the PropMaker in warm yellow. Upload this code first so you know when you've got the wiring right.

It's also easier (and more fun) to work the pixels into the dress when they're turned on, so you can see what you're getting.

You can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **Download Project Bundle** button in the window below. It will download to your computer as a zipped folder.&nbsp;

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

## Upload the Code and Libraries to the RP2040 Prop-Maker Feather

After downloading the Project Bundle, plug your RP2040 Prop-Maker Feather into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called **CIRCUITPY**. Unzip the folder and copy the following items to the RP2040 Prop-Maker Feather's **CIRCUITPY** drive.

- **lib** folder
- **code.py**

Your RP2040 Prop-Maker Feather **CIRCUITPY** drive should look like this after copying the **lib** folder,&nbsp;and the **code.py** file.

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/PolkaDot_Dress_test.png )

Plug your lights into the board and power it up, and they should all come on in yellow.

If you need to modify the code (and you likely will at the final step), follow this tutorial to install a code editor and learn to use the serial monitor to debug and calibrate your sensor.

[Welcome to CircuitPython!](https://learn.adafruit.com/welcome-to-circuitpython/creating-and-editing-code) - an Introductory Tutorial

&nbsp;

# Polka Dot Electro-Swing Dress with NeoPixels

## Electronics Assembly

Cut the male connector off the OUT end of your seed pixel strand. Strip a little shielding from the three wires and insert them into the screw terminal on the PropMaker as shown:&nbsp;

- Red wire to **+5v**
- White wire to **G**
- Green wire to **NEO**

Or, if you're using one of the Adafruit all-black JST connectors, first plug it into the female connector on the seed pixel strand to verify which wire corresponds with which color, and connect it in the same manner.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/921/medium640/led_pixels_controller.jpg?1784667288)

Plug the controller into the IN end of the light strand with the connector. If you've uploaded the test code from the previous page, the lights should all come on in yellow.&nbsp;

If they're a different color, you can change the `COLOR_ORDER` in the code - you know you have it right if they're yellow.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/923/medium640/led_pixels_wired.png?1784668604)

## Troubleshooting

If your lights don't come on or behave the way you expect, here are a few things to try:

- Try re-uploading the software
- Make sure your Data IN is connected to the NEO pin and double check all your wiring.
- If the lights still don't come on, your strand may be wired a different way. Sometimes these strands come with the male on the OUT end and female on the IN. Try switching the connectors around to plug in the other end of the strand.

# Polka Dot Electro-Swing Dress with NeoPixels

## Pixel Layout

The polka dot pattern on the dress makes so many different pixel layouts possible, so put some thought into what areas you'd like to light.

On my dress, the pixels reach comfortably from one polka dot to the next if I go in a diagonal pattern along the print, but if I try to span two columns of polka dots (and go horizontal) they just don't quite reach. So, diagonal it is!&nbsp;

These pixels are pretty sturdy, but I still wanted to avoid putting pixels in areas where they'll be under a lot of stress. I avoided the seat and back area altogether, so I can sit down or ride in a car in this dress without worrying about putting too much strain on the pixel strand. I also avoided the yoke area around the waist, since I may want to add a belt or waist cincher there -- and areas that get flexed a whole lot are in more danger of breaking.

I kept all the pixels in one long strand, so I didn't have to do any soldering. You can run about 300 pixels in a row before you need to power-inject, so this keeps everything simple. My dress has 216 pixels, so it fits nicely within that range. If you have more than 300 pixels, consider using multiple data pins and shorter strands, or injecting power further down the line.

It's possible to turn some of the pixels off in the code, so if there's a run that goes past a place you want to stay dark, that's no problem - do what works best with your vision.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/144/920/medium800/led_pixels_dress_layout-3.jpg?1784662206)

I started with pixel 0 near the waistband, so I can attach the controller and battery there within easy reach. I then zig-zagged up and down one side of the dress, following the pattern. This dress is pretty well matched along the seam line which made this layout look great.

I then went along the lower back and under the zipper, then repeated the sequence on the other hip. I ended up near the waistline, and ran a couple pixels up through the yoke and zig-zagged across both cups, hiding an extra (darkened) pixel in the center front at the solar plexus.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/924/medium800/led_pixels_IMG_6612.jpeg?1784668936)

# Polka Dot Electro-Swing Dress with NeoPixels

## Dress Assembly

I tried a few different methods of attaching the pixels to this dress with varied success.&nbsp;The method I settled on for this project does a great job of keeping the pixels in place behind the polka dots with minimal sewing while keeping the fabric fairly unwrinkled and unblemished. I'm not sure how it will hold up to washing - I plan to wash by hand, in cold water, with the battery and controller removed.

For other ideas, check out these guides:

- [Water Drip Dress](https://learn.adafruit.com/water-drip-dress-with-oozemaster-3000/overview)
- [Festival Coat with Mapping](https://learn.adafruit.com/led-festival-coat-with-mapping-and-wled)
- [Sparkle Skirt Playground](https://learn.adafruit.com/sparkle-skirt-playground)
- [Sparkle Motion Skirt with Mapping](https://learn.adafruit.com/sparkle-motion-skirt-with-2d-mapping)
- [Starlite Groove Tutu](https://learn.adafruit.com/starlight-groove-tutu-sound-reactive-led-skirt)

## Attachment Failure 1: Underskirt Method

For past projects, I've preferred putting the pixels on a slip or under-skirt, so the outer dress can remain somewhat untouched and easy to wash. My first attempt used that method, but I was really unhappy with the results. It was really hard to guess exactly where the pixels should land, spacing-wise, and then even when I got it close the whole design looked blurry. The polka dot layer did not stay lined up with the pixel-laden slip and the geometric pattern was lost.

It's much better to attach the pixels directly to the dress, in this case.&nbsp;

&nbsp;

## Attachment Failure 2: Sewing

Next, I tried sewing the pixels to the dress on the inside using machine bar tacks across the wire.

This looked terrible: the dress is mostly polyester and pretty thin, and it shows everything. I didn't want a messy wire line showing all throughout the dress, pulling the dots out of alignment.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/144/914/medium640/led_pixels_sewing_pixels_bad.jpeg?1784660171)

## Attachment Success: Glue Dots & Interfacing

[Zots 3d glue dots](https://a.co/d/0ippkybd) are a fantastic method for attaching the pixels to the polka dots. These glue dots are just slightly smaller than the polka dots and are thick enough to press the pixel into, and very sticky on both sides. The pixel presses firmly into the glue and, as a serious bonus, diffuses the light into a polka-dot sized circle. Instead of one tiny point of light, the seed pixel now makes the whole polka dot glow.&nbsp;

To keep the dress from sticking to itself on the inside, and to make sure the dots stay in place, I used featherweight black iron-on interfacing over the whole inside section, covering all the glue dots and wires and fusing to the inside of the fabric so the whole assembly is encased in a layer of interfacing.

Working one section at a time: Stick a glue dot onto the inside of each polka dot. Press the pixels into the glue dots. I angled each pixel just a little bit - left, then right, then left - to give the wire a bit of a zig-zag shape so the pixels don't pull the fabric out of shape, and everything lays flat.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/913/medium640/led_pixels_gluedots2.jpeg?1784659701)

Cut small strips of interfacing and place them glue-side-down on top of the pixel strand, making sure all the wires are encased. It's easiest to work in small sections - this stuff sticks to itself very well so layering it up a bit is fine.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/915/medium640/led_pixels_interfacing.jpeg?1784660833)

Use an iron on medium-high heat to bond the interfacing to the dress. Be very careful here and mostly focus on placing the tip of the iron on the spots where the interfacing can touch the dress directly: i.e. try to iron AROUND the wires and glue dots if you can.&nbsp;

Going over the glue dots a bit won't hurt them, and will melt them into the fabric a little for even better adhesion, but they will burn through the fabric if you get them too hot, so take your time!

Try to get the fabric as smooth as possible beneath the interfacing. Any wrinkles that get ironed in at this stage will be there forever.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/916/medium640/led_pixels_iron.jpeg?1784661050)

My dress has a double layer of fabric on the top for the cups. To get the pixels inside and aligned with the outer layer, I cut through the side seams and took out a few of the stitches along the yoke edge. I turned the cup section inside-out to work on it.&nbsp;

In hindsight it may have been easier to take these sections completely apart and work on ONLY the outer layer. Getting these to iron flat was a chore.

I threaded the pixels up through the yoke at the side seam and then down through the yoke at the center front when going from one side to the next.&nbsp;

Adding the interfacing for this part was super tricky since there are pleats in the fabric as well. I just took my time and went slowly and carefully.&nbsp;&nbsp;

The fabric did end up a bit wrinkly, and you can see a couple of the glue stains through the dots, but it still looks fabulous when I step back a couple feet.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/917/medium640/led_pixels_top_pixels.jpeg?1784661221)

![](https://cdn-learn.adafruit.com/assets/assets/000/144/918/medium640/led_pixels_sewup.jpeg?1784661361)

![](https://cdn-learn.adafruit.com/assets/assets/000/144/926/medium800/led_pixels_rainbow.jpg?1784669278)

## Battery & Controller Pocket
For strain relief on the connector, fold it along the bottom side of the board so it wraps around and comes out the same side as the USB port.

Grab your 1" heat shrink and cut a piece that's slightly longer than the controller. Slide it on and shrink it down, making sure the USB port is accessible and the connector is solid.

Squirt a little bit of hot glue into the screw terminal end of the heat shrink to keep the wires from wiggling or pulling out. If you ever need to replace the connector or remove the board, a little rubbing alcohol will remove the hot glue cleanly and neatly.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/936/medium640/led_pixels_heathsrink.jpeg?1784745922)

Plug the battery into the power switch tail and plug the controller in to the other end.&nbsp;

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/144/935/medium640/led_pixels_powersupply.png?1784745815)

Make a pocket for the electronics that lives under the dress. I made mine easily removable by sewing the soft side of some velcro into the waistband of the dress, then sewing the pokey side into the pocket. I put velcro in the top of the pocket as well so the electronics don't fall out if I throw the dress in a bag or drape it over a hanger.&nbsp;

This makes it easy to remove all the electronics when you want to wash the dress -- just unplug the connector and you're good to go.

![](https://cdn-learn.adafruit.com/assets/assets/000/144/937/medium640/led_pixels_batterypocket.jpeg?1784746086)

# Polka Dot Electro-Swing Dress with NeoPixels

## Pixel Mapping

NeoPixels are numbered according to their position in the strand, starting with pixel 0. The code knows the order in which the pixels are wired, but it doesn’t automatically know where each pixel sits on the dress.&nbsp;

Doing a full pixel map is possible, but for a low-res flame/ember effect it's a little more than I need. Instead, I've divided the pixels into height groups. The animations will start near the hem, then move to the skirt middle, skirt top, and then dress top.&nbsp;

Your pixel layout will probably be different from mine. Use the pixel-identification code below to find each pixel number and create your own sections. The final code supports four different height sections of pixels: skirt bottom, skirt middle, skirt top, and dress top.

## Pixel Identification Code

This is a cool mapping tool script that turns on each pixel one at a time for a few seconds, and gives you the currently-lit pixel number in the serial monitor. This way, even if your pixels are laid out in diagonals or spirals, you can still select and focus on only the pixels you want to light up.&nbsp;

You can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **Download Project Bundle** button in the window below. It will download to your computer as a zipped folder.&nbsp;

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

## Upload the Code and Libraries to the RP2040 Prop-Maker Feather

After downloading the Project Bundle, plug your RP2040 Prop-Maker Feather into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called **CIRCUITPY**. Unzip the folder and copy the following items to the RP2040 Prop-Maker Feather's **CIRCUITPY** drive.

- **lib** folder
- **code.py**

Your RP2040 Prop-Maker Feather **CIRCUITPY** drive should look like this after copying the **lib** folder,&nbsp;and the **code.py** file.

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/PolkaDot_Dress_final.png )

Change `NUM_PIXELS` to match the total number of pixels in your project.

`PIXEL_DELAY` controls how long each pixel remains illuminated. Increase this value if the sequence moves too quickly for you to identify and record each pixel. Right now each pixel stays on for 4 seconds.

## Identify the Pixel Numbers

Save the program as `code.py` on the CIRCUITPY drive and open the serial monitor.

The code will turn on one pixel at a time while printing its number:

```
Pixel: 0
Pixel: 1
Pixel: 2
Pixel: 3
```

Choose a dividing line for the top, middle, and bottom sections. Watch the dress as each pixel turns on, and write each pixel number into one of these groups:

- Lower skirt

- Middle skirt

- Upper skirt

The sequence repeats after a short pause, so don’t worry if you miss a few pixels on the first pass.

## Check Your Lists

Before returning to the main dress code, check that:

- Every pixel number is between `0` and `NUM_PIXELS - 1`.

- Every skirt pixel appears in one height group.

- No skirt pixel appears in more than one height group.

- The top pixels don’t appear in the skirt groups.

Here's what my final map list looks like:&nbsp;

> high 0, 1, 2, 3, 4, 14, 15, 16, 17, 18, 19, 20, 21, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 161, 162, 163, 164, 165
> 
> med &nbsp;5, 6, 7, 8, 9, 10, 11, 12, 13, 22, 23, 24, 25, 26, 35, 36, 37, 38, 50, 51, 52, 53, 54, 69, 70, 71, 72, 73, 91, 92, 93, 94, 108, 109, 110, 111, 112, 126, 127, 128, 136, 137, 138, 139, 140, 152, 153, 154, 155, 156, 157, 158, 159, 160
> 
> low &nbsp;27, 28, 29, 30, 31, 32, 33, 34, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, &nbsp;129, 130, 131, 132, 133, 134, 135

I used an LLM to look over my list to make sure every number is represented and I don't have any duplicates. It found my mistakes so I could correct them and test.

&nbsp;

# Polka Dot Electro-Swing Dress with NeoPixels

## Code the Dress

You can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **Download Project Bundle** button in the window below. It will download to your computer as a zipped folder.

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

## Upload the Code and Libraries to the RP2040 Prop-Maker Feather

After downloading the Project Bundle, plug your RP2040 Prop-Maker Feather into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called **CIRCUITPY**. Unzip the folder and copy the following items to the RP2040 Prop-Maker Feather's **CIRCUITPY** drive.

- **lib** folder
- **code.py**

Your RP2040 Prop-Maker Feather **CIRCUITPY** drive should look like this after copying the **lib** folder,&nbsp;and the **code.py** file.

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/PolkaDot_Dress_final.png )

The code creates two different looks: a gentle bed of glowing embers while the dress is at rest, and a bright flare that races from the hem to the bodice when the wearer makes a large movement.

The dress is divided into four horizontal levels instead of following the physical order of the NeoPixel strand. This lets the animation move vertically even though the wiring zigzags between the front and back of the dress.

## Pixel Setup

At the beginning of the code, set the total number of pixels and the overall brightness:

```
NUM_PIXELS = 216
BRIGHTNESS = 0.8
```

Change `NUM_PIXELS` to match the number of NeoPixels in your project.

`BRIGHTNESS` controls the maximum brightness of the entire strand. Use a value between `0.0` and `1.0`. Lower this number to reduce both brightness and power consumption.

## Dress Levels

The pixel strand travels back and forth across the dress, so consecutive pixel numbers aren’t necessarily next to one another vertically. To make the flare travel upward, the pixels are sorted into four height groups. These are the lists you made on the Pixel Mapping page. Update the code to reflect your pixel numbers for each section.

The top of my dress is just one section and includes every pixel from 166-216. For all-inclusive blocks of pixels, you don't need to write out every number, but instead can declare a tuple range.&nbsp;

```auto
# --------------------------------------------------
# DRESS LEVELS
# --------------------------------------------------

UPPER_SKIRT_PIXELS = (
    0, 1, 2, 3, 4,
    14, 15, 16, 17, 18, 19, 20, 21,
    39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
    74, 75, 76, 77, 78, 79, 80,
    81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
    113, 114, 115, 116, 117, 118, 119, 120,
    121, 122, 123, 124, 125,
    141, 142, 143, 144, 145, 146, 147, 148,
    149, 150, 151,
    161, 162, 163, 164, 165
)

MIDDLE_SKIRT_PIXELS = (
    5, 6, 7, 8, 9, 10, 11, 12, 13,
    22, 23, 24, 25, 26,
    35, 36, 37, 38,
    50, 51, 52, 53, 54,
    69, 70, 71, 72, 73,
    91, 92, 93, 94,
    108, 109, 110, 111, 112,
    126, 127, 128,
    136, 137, 138, 139, 140,
    152, 153, 154, 155, 156, 157, 158, 159, 160
)

LOWER_SKIRT_PIXELS = (
    27, 28, 29, 30, 31, 32, 33, 34,
    55, 56, 57, 58, 59, 60, 61, 62,
    63, 64, 65, 66, 67, 68,
    95, 96, 97, 98, 99, 100, 101, 102,
    103, 104, 105, 106, 107,
    129, 130, 131, 132, 133, 134, 135
)

TOP_LEVEL_PIXELS = tuple(range(166, 216))
```

## Motion Detection

The onboard LIS3DH accelerometer continuously measures the dress’s movement. The code compares the total acceleration with normal gravity to estimate how dramatically the dress is moving.

```
MOTION_THRESHOLD = 5.0
```

This is the main motion-sensitivity setting. Lower it if the flare is difficult to trigger. Raise it if ordinary walking or small movements trigger the flare too often.

The motion readings are smoothed to keep a single noisy sensor reading from creating a false trigger:

```
MOTION_SMOOTHING = 0.25
```

Higher values react more quickly but may be jumpier. Lower values produce smoother readings but may make the dress respond a little more slowly.

```
TRIGGER_COUNT_REQUIRED = 1
```

This controls how many consecutive readings must exceed the threshold. Increase it to `2` or `3` if you need more protection against accidental triggers.

After a flare, the code waits briefly before allowing another one:

```
FLARE_COOLDOWN = 0.4
```

Increase this value if repeated movement causes the effect to retrigger too quickly.

## Calibrate the Motion Sensor

Set this variable to `True` while testing:

```
DEBUG_MOTION = True
```

Open the serial console and move the dress the way you expect to move while wearing it. The console will display the current motion reading and threshold:

```
Motion: 3.72 Threshold: 5.0
```

Watch the readings produced by normal movement and by the larger gesture you want to use as the trigger. Choose a `MOTION_THRESHOLD` that falls between those values.

Set `DEBUG_MOTION` back to `False` once the motion response feels right.

## The Ember Effect

While the dress is waiting for a large movement, `ember_frame()` creates a shifting field of dim red and orange embers.

The lower skirt receives the most activity:

```
LOWER_EMBER_WEIGHT = 0.55
MIDDLE_EMBER_WEIGHT = 0.30
UPPER_EMBER_WEIGHT = 0.15
```

These three values represent the likelihood that a new ember will appear in each level. Together, they should add up to `1.0`.

Increase `LOWER_EMBER_WEIGHT` to concentrate more of the glow around the hem. Use more even values if you want the embers spread across the whole skirt.

The number of new embers added to each animation frame is controlled here:

```
MIN_EMBERS_PER_FRAME = 4
MAX_EMBERS_PER_FRAME = 8
```

Use smaller numbers for a quieter effect or larger numbers for a busier field of sparks.

Existing embers fade a little during every frame:

```
EMBER_FADE_AMOUNT = 4
```

A lower value makes each ember linger longer. A higher value makes the pixels fade more quickly.

Occasionally, the code adds a brighter hot spark:

```
HOT_SPARK_CHANCE = 0.14
```

Increase this value for more frequent sparks or decrease it for a calmer effect.

## The Flare Animation

When the motion level crosses the threshold, `flare_up()` runs the main effect.

The function shuffles the pixels within each level so the flare doesn’t appear as a perfectly straight band. It then illuminates the four levels in order:

```
LOWER_SKIRT_PIXELS
MIDDLE_SKIRT_PIXELS
UPPER_SKIRT_PIXELS
TOP_LEVEL_PIXELS
```

This makes the light appear to rush from the hem toward the bodice, regardless of the physical wiring order.

The speed of the upward movement is controlled by:

```
flare_frames = 12
```

Decrease this number to make the flare travel faster. Increase it for a slower, more gradual rise. Avoid setting it below `2`, since the animation uses the frame count to calculate its progress.

After reaching the top, the code creates a short burst of brighter sparks across the skirt. The top continues flickering and then gradually fades into an animated afterglow.

## &nbsp;
![](https://cdn-learn.adafruit.com/assets/assets/000/144/927/medium800/led_pixels_brighteyes.jpeg?1784669476)


## Guide Products

### Adafruit NeoPixel Pebble / Seed LED Strand - 300 LEDs - 2" Pitch

[Adafruit NeoPixel Pebble / Seed LED Strand - 300 LEDs - 2" Pitch](https://www.adafruit.com/product/6023)
We have all&nbsp;sorts of LED strips for a wide range of needs.&nbsp;[_Chonky_](https://www.adafruit.com/product/3869)&nbsp;strips? We got those!&nbsp;[Strips with alligator...](https://www.adafruit.com/?q=neopixel%20alligator%20clips%20stripping%20wires)

In Stock
[Buy Now](https://www.adafruit.com/product/6023)
[Related Guides to the Product](https://learn.adafruit.com/products/6023/guides)
### 3-pin JST SM Plug + Receptacle Cable Set

[3-pin JST SM Plug + Receptacle Cable Set](https://www.adafruit.com/product/1663)
These 3-wire cables are 163mm (6.4") long and come as a set. One cable has a JST SM type connector plug on the end. The other cable has a matching JST SM type receptacle connector. They are good for whenever you have 3 wires you want to be able to plug and unplug. We like the solid and...

In Stock
[Buy Now](https://www.adafruit.com/product/1663)
[Related Guides to the Product](https://learn.adafruit.com/products/1663/guides)
### Adafruit RP2040 Prop-Maker Feather with I2S Audio Amplifier

[Adafruit RP2040 Prop-Maker Feather with I2S Audio Amplifier](https://www.adafruit.com/product/5768)
The Adafruit Feather series gives you lots of options for a small, portable, rechargeable microcontroller board. By picking a feather and stacking on a FeatherWing you can create advanced projects quickly. One popular combo is our [Feather M4](https://www.adafruit.com/product/3857)...

In Stock
[Buy Now](https://www.adafruit.com/product/5768)
[Related Guides to the Product](https://learn.adafruit.com/products/5768/guides)
### USB Type C Sync Data Cable with On-Off Switch - 28cm long

[USB Type C Sync Data Cable with On-Off Switch - 28cm long](https://www.adafruit.com/product/6268)
This **USB Type C Sync Data Cable with On/Off Switch** &nbsp;cable is great when you don't want to plug-and-unplug a device to turn it on and off. It's a true USB C to C cable, with power, data and power delivery (USB C PD)&nbsp;lines connected so it can be used for high...

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

## Related Guides

- [Adafruit RP2040 Prop-Maker Feather](https://learn.adafruit.com/adafruit-rp2040-prop-maker-feather.md)
- [StarFlower NeoPixel Strand with MakeCode](https://learn.adafruit.com/starflower-neopixel-strand.md)
- [Adabot Toy Robot Friend](https://learn.adafruit.com/adabot-rp2040.md)
- [Mario Magic Wand](https://learn.adafruit.com/mario-magic-wand.md)
- [Audio Synthesis with CircuitPython synthio](https://learn.adafruit.com/audio-synthesis-with-circuitpython-synthio.md)
- [PropMaker Jack O'Lantern](https://learn.adafruit.com/propmaker-jack-o-lantern.md)
- [Prop It Game](https://learn.adafruit.com/prop-it-game.md)
- [Bricktunes: LEGO Synthesizer Glove](https://learn.adafruit.com/bricktunes-lego-glove-synthesizer.md)
- [Sparkle Motion Christmas Tree Lights](https://learn.adafruit.com/sparkle-motion-christmas-tree-lights.md)
- [Close Encounters of the MIDI NeoPixel Visualizer Kind](https://learn.adafruit.com/midi-neopixel-visualizer.md)
- [Color Sensing Music Player](https://learn.adafruit.com/color-sensing-music-player.md)
- [MIT Green Building NeoPixel Tetris](https://learn.adafruit.com/tetris-building.md)
- [Programmable 12v Outdoor Cafe Lights](https://learn.adafruit.com/programmable-12v-outdoor-cafe-lights.md)
- [Motion Sensor Bat](https://learn.adafruit.com/motion-sensor-bat.md)
- [Haunted Air Blaster](https://learn.adafruit.com/automated-air-blaster.md)
- [Water Drip Dress with Oozemaster 3000](https://learn.adafruit.com/water-drip-dress-with-oozemaster-3000.md)
