# Adafruit Sparkle Motion Stick

## Overview

![gif of the sparkle motion stick powering neopixels](https://cdn-learn.adafruit.com/assets/assets/000/136/842/medium800thumb/adafruit_products_6332-00.jpg?1747249902 )

The **Adafruit Sparkle Motion Stick** is part of our series of "Sparkle Motion" boards, which are our attempt to make the best small WLED-friendly smart LED driving board in the whole world. Our resident mermaid, [firepixie](https://learn.adafruit.com/u/firepixie) makes a lot of projects with WLED, and she loves it! So, how can we make something powerful enough to drive advanced LED projects that need a compact design?

![sparkle motion sttick in case](https://cdn-learn.adafruit.com/assets/assets/000/137/072/medium800/adafruit_products_6333-06.jpg?1747956007 )

The USB Stick version of the Sparkle Motion is a simpler version of our full-featured Sparkle Motion. [It even fits into a low cost off-the-shelf case for protection](https://www.adafruit.com/product/6176). **Please note the case is not included with this product** , so don't forget to pick one up if you want it in a case!

![front view of the stick](https://cdn-learn.adafruit.com/assets/assets/000/136/843/medium800/adafruit_products_6332-04.jpg?1747250004 )

- **Power via USB Type A for up to 5V 2A input -&nbsp;** you can use off-the-shelf USB battery packs for portable operation.
- **2&nbsp;Amp resetting fuse&nbsp;** to protect from over-current drive
- **ESP32** &nbsp;mini module with built-in antenna port - the classic ESP32 has the best WLED support, even if we'd prefer the 'S2 or 'S3. Comes with 4 MB of flash, dual-core 240MHz Tensilica, WiFi, Bluetooth LE, and Bluetooth Classic support.
- **USB-serial converter&nbsp;** with auto-reset
- **Two output signals plus 5V power and ground** &nbsp;- both signal outputs are level shifted to 5V.
- **Built-in I2S microphone&nbsp;** for audio-reactive projects
- **Built-in Infrared receiver&nbsp;** on GPIO 10&nbsp;for easy remote control integration
- **User button on GPIO 0** &nbsp;which you can press even when its in the snap-on case
- **Red built-in LED** &nbsp;on pin 4
- **Small built-in NeoPixel** &nbsp;on pin 18
- **Screw terminal blocks** &nbsp;for no-solder connectivity

![sparkle motion stick in case with cap](https://cdn-learn.adafruit.com/assets/assets/000/137/073/medium800/adafruit_products_6333-03.jpg?1747956047 )

Compared to our [larger Sparkle Motion board](https://www.adafruit.com/product/6100), this only supports 5V and doesn't have a reset button, there are fewer outputs, and no breakout pads of I2C/GPIO connections for external accessories.

Compared to our&nbsp;[Sparkle Motion Mini](https://www.adafruit.com/product/6160), this has a USB A port so it's 2A max power. It does have IR and built-in terminal blocks but does not have GPIO breakout pads.

![back view of the stick](https://cdn-learn.adafruit.com/assets/assets/000/136/844/medium800/adafruit_products_6332-01.jpg?1747250050 )

While we recommend it for use with WLED, it will also work just fine as a compact ESP32 board for use with Arduino, ESP-IDF, MicroPython, CircuitPython, or any other ESP32-supported codebase.

# Adafruit Sparkle Motion Stick

## Pinouts

![front and back views of the board](https://cdn-learn.adafruit.com/assets/assets/000/136/859/medium800/adafruit_products_double.jpg?1747321856 )

The Adafruit Sparkle Motion Stick is a miniature board with a lot of sparkly features.&nbsp;

![sparkle motion stick prettypins](https://cdn-learn.adafruit.com/assets/assets/000/137/013/medium800/adafruit_products_Artboard_1.png?1747841616 )

PrettyPins PDF [on GitHub.](https://github.com/adafruit/Adafruit-Sparkle-Motion-Stick-PCB/blob/main/Adafruit_Sparkle_Motion_Stick_PrettyPins.pdf)

## Power Pins
![power pins and usb a](https://cdn-learn.adafruit.com/assets/assets/000/136/870/medium800/adafruit_products_pwr.jpg?1747323140 )

- **USB-A port** - This is used for both powering and programming the board. You can power it by plugging it into a USB A port on a computer, USB A power supply (like a phone charger) or USB A battery pack. It is a 5V 2A input -&nbsp;you can use off-the-shelf USB battery packs for portable operation. **It is connected to a**  **2&nbsp;Amp resetting fuse&nbsp;** to protect from overcurrent drive.
- **5V** - This pin, located in the bottom right corner terminal block on the board, is the output from the 5V regulator. Its meant to power your 5V pixels.
- **Power LED** - The green LED, located in the bottom left corner on the front of the board (labeled **5** for 5V on the board silk), indicates when the board is powered up.
- **GND** - This is the common ground for all power and logic.

## ESP32 Module
![esp32 module](https://cdn-learn.adafruit.com/assets/assets/000/136/869/medium800/adafruit_products_esp32.jpg?1747323121 )

The processor on the Sparkle Motion Stick is an&nbsp; **ESP32 mini module**. The classic ESP32 has the best WLED support. Comes with 4 MB of flash, dual core 240MHz Tensilica, WiFi, Bluetooth LE and Bluetooth Classic support.

## NeoPixel Output Signals
![neopixel output terminal blocks](https://cdn-learn.adafruit.com/assets/assets/000/136/868/medium800/adafruit_products_neoOut.jpg?1747323106 )

On the right edge of the board are two NeoPixel output signals. Both signals are level shifted to 5V and are on 0.1" spaced breakout pads.

- **21** - GPIO21, available as **D21** in CircuitPython and **21** in Arduino
- **22** - GPIO22, available as&nbsp; **D22** in CircuitPython and **22** in Arduino.

## NeoPixel and Red LED
![neopixel and red led](https://cdn-learn.adafruit.com/assets/assets/000/136/867/medium800/adafruit_products_leds.jpg?1747323090 )

There are two LEDs you can control in code.

- **NeoPixel LED** - This addressable RGB NeoPixel LED, labeled **Neo** on the board, can be controlled with code. It acts as a status LED in CircuitPython and is connected to GPIO18.&nbsp;It is available in CircuitPython as `board.NEOPIXEL`, and in Arduino as `PIN_NEOPIXEL`.
- **Red LED** - This little red LED, labeled **4** on the board, is on or blinks during certain operations (such as pulsing when in the bootloader), and is controllable in code. It is available in CircuitPython as `board.LED`, and in Arduino as `LED_BUILTIN` or `4`.

## Button
![boot button in the center of the board](https://cdn-learn.adafruit.com/assets/assets/000/136/866/medium800/adafruit_products_button.jpg?1747323076 )

- **Boot button** - This button can be read as an input in code. It is connected to pin **GPIO0**. It is available as `board.BUTTON` in CircuitPython, and `BUTTON` in Arduino. Simply set it to be an input with a pullup. This button can also be used to put the board into&nbsp;_ROM bootloader mode_. To enter ROM bootloader mode, hold down boot button while powering up the board. When in the ROM bootloader, you can upload code and query the chip using `esptool`.

## IR Receiver
![ir receiver](https://cdn-learn.adafruit.com/assets/assets/000/136/865/medium800/adafruit_products_ir.jpg?1747323058 )

The IR Receiver on the top center of the board makes it easy integrate a remote control into your project.

**IR** - GPIO10. Available as `board.IR` in CircuitPython, and `10` in Arduino. It is connected to ADC2.

## I2S Microphone
![i2s mic](https://cdn-learn.adafruit.com/assets/assets/000/136/864/medium800/adafruit_products_i2s.jpg?1747323032 )

In the center of the board is an I2S microphone, great for adding audio reactivity to your WLED projects. It uses three data pins:

- **WS** - GPIO12
- **DATA&nbsp;** - GPIO13
- **BCLK** - GPIO14

You can use the microphone with WLED and Arduino. **There is no I2S input support in CircuitPython at this time.**

## CH343 USB-to-Serial Converter
![usb serial converter chip](https://cdn-learn.adafruit.com/assets/assets/000/136/863/medium800/adafruit_products_usbSerial.jpg?1747323015 )

The **CH343 USB to serial converter** communicates between the ESP32 and your computer over USB. It is a full-speed USB device interface and is USB 2.0 compatible. It has an auto-reset circuit that works perfectly with any ESP32 uploading tool. Sometimes these chips require drivers to be installed on your computer's operating system. We have a [Learn Guide detailing how to install these drivers.](https://learn.adafruit.com/how-to-install-drivers-for-wch-usb-to-serial-chips-ch9102f-ch9102)

# Adafruit Sparkle Motion Stick

## WLED Installation

This page will guide you through how to install WLED on the Sparkle Motion Stick and connect a NeoPixel strip to test it.

### Adafruit NeoPixel Digital RGB LED Strip - Black 30 LED 1m

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

Out of Stock
[Buy Now](https://www.adafruit.com/product/2552)
[Related Guides to the Product](https://learn.adafruit.com/products/2552/guides)
![Angled shot of lit RGBW LED strip on a reel.](https://cdn-shop.adafruit.com/640x480/2552-00.jpg)

## USB Serial Driver Update

The Sparkle Motion Stick has a USB to serial chip which may need a driver installed before you can install WLED. Head over to the [How to Install Drivers for WCH USB to Serial Chips](https://learn.adafruit.com/how-to-install-drivers-for-wch-usb-to-serial-chips)&nbsp;tutorial, and download and install the new driver.

## Pre-Release Version of WLED
At this time, the Sparkle Motion Stick works best with 0.16 -- the IR receiver is not supported in WLED 0.15. This should be fixed in the next release of WLED.

If you **don't** need to use the IR receiver, you can proceed with the default installation steps after this section.

To use the IR receiver now, the following combined .bin file can be used. Get it by downloading this zip file:

[esp32_bootloader_v4_WLED_0.16.0-alpha_ESP32](https://cdn-learn.adafruit.com/assets/assets/000/134/984/original/esp32_bootloader_v4_WLED_0.16.0-alpha_ESP32.zip?1738630454)
To install, extract the .bin file from the zip and then follow the same&nbsp;[ESB Web Flasher process used for installing CircuitPython](https://learn.adafruit.com/adafruit-sparkle-motion-stick/install-circuitpython#connecting-to-the-web-flasher-3125650). At the "Programming the Board" step, choose the .bin file and leave offset as 0x0.

## Install WLED

These next steps require a **_Web Serial_-compatible browser**. As of this writing, that means **Google&nbsp;Chrome** , **Microsoft&nbsp;Edge** or **Opera** &nbsp;“desktop” browsers. Other browsers (Safari, Firefox, Explorer and _anything_ mobile) won’t work.

Visit [https://install.wled.me/](https://install.wled.me/)

Plug your microcontroller into your computer with a known good USB cable. Click "Install" and select the port for your board.

Depending on the USB-to-serial bridge chip on the board, you might see one _or two_ serial ports. On Mac, for instance, there might be both “/dev/cu.usbmodem[number]” _and_ “/dev/cu.wchusbserial[number]”. Use the “ **wchusbserial** ” one.

![adafruit_products_Install_WLED.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/287/medium640/adafruit_products_Install_WLED.jpg?1663802069)

After successful installation, enter your WiFi network name and password when prompted. This must be a **2.4 GHz** WiFi network; ESP32 does not support 5 GHz networks. If it can’t connect, then as a fallback WLED will create its own 2.4 GHz WiFi access point.

![led_strips_Install_WLED.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/601/medium640/led_strips_Install_WLED.jpg?1737574345)

If you don't see the "Connect to Wi-Fi" prompt, you'll need to set up your WiFi network using AP (access point) mode.&nbsp;Open up your WiFi settings and look for a WiFi network called&nbsp;`WLED-AP`. Connect to this network&nbsp;using the default password&nbsp;`wled1234`. The WLED interface will pop up in its own browser.

From here, go into Config/Wifi Settings and enter your WiFi credentials near the top. Give your project a name in the mDNS field a little further down the page. Now you can type in "projectname.local" (where "projectname" is your mDNS name) into any web browser on the same wifi network to access your microcontroller.

You can also scan the QR code below to open access point mode.&nbsp;

For more help and troubleshooting tips visit the [Getting Started page on the WLED knowledge base.](https://kno.wled.ge/basics/getting-started/)

![led_strips_install_no_wifi.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/597/medium640/led_strips_install_no_wifi.jpg?1737574050)

![led_strips_WLED_wifi_settings.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/598/medium640/led_strips_WLED_wifi_settings.jpg?1737574103)

![](https://cdn-learn.adafruit.com/assets/assets/000/134/599/medium800/led_strips_WLED-QR-Connect-WB.png?1737574151)

## Setup & Preferences
### WiFi&nbsp;Setup

Head to the **WiFi Setup** screen under Config and create a good URL so you can control your project from any web-enabled device. Call it something you'll remember, that's easy to type into any web browser on your WiFi network in order to connect to your project.

In Safari or Chrome on your phone or computer, type in this web address to access the WLED interface: [http://projectname.local](http://projectname.local)&nbsp; (where "projectname" is whatever you put into this field).

Check out the Additional Settings page for more info on accessing your project. WLED has an "access point mode" that doesn't require a WiFi network for when you're out on the go. It's also helpful to download one of the WLED apps to help manage and organize your projects.

![adafruit_products_wled_config.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/288/medium640/adafruit_products_wled_config.jpg?1663802411)

![led_strips_adafruit_products_WiFi_Settings_generic.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/679/medium640/led_strips_adafruit_products_WiFi_Settings_generic.jpg?1722624553)

## Wiring

You'll connect a NeoPixel strip to pin 21 on the Sparkle Motion Stick.

- **NeoPixel Din** to **Sparkle Motion 21 (blue wire)**
- **NeoPixel +5V** to **Sparkle Motion 5V (red wire)**
- **NeoPixel GND** to **Sparkle Motion GND (black wire)**

![fritzing diagram with neopixels](https://cdn-learn.adafruit.com/assets/assets/000/136/993/medium640/adafruit_products_wledNeo.jpg?1747770203)

## LED Setup

Next, head to the&nbsp; **LED Preferences** &nbsp;tab under the&nbsp; **Config menu**.

Scroll down to&nbsp; **Hardware Setup**. Put your total number of LEDs into the **&nbsp;Length** &nbsp;field, and change GPIO to 21 for your Sparkle Motion Stick. Make sure to select the correct&nbsp; **Color Order** &nbsp;for your LEDs as well.

![hardware setup](https://cdn-learn.adafruit.com/assets/assets/000/136/992/medium640/adafruit_products_Screenshot_2025-05-16_155359.jpg?1747769946)

## Use It
![adafruit_products_WLED_interface.jpg](https://cdn-learn.adafruit.com/assets/assets/000/115/394/medium800/adafruit_products_WLED_interface.jpg?1667150591)

Now you can use any computer or handheld device to control your LEDs.&nbsp;

Make sure your device is on the same WiFi network as your board. Navigate to your custom URL (projectname.local/ ) in a web browser. You'll see a color picker above a whole bunch of color palette choices.

Choose a color, choose an effect, and watch your lights animate and glow!

Save your favorite combinations as presets, create playlists, control the speed and intensity of the animations, and lots more. This web app is incredibly intuitive and easy to use.

Head over to the WLED wiki at [https://kno.wled.ge/](https://kno.wled.ge/) to delve into all the particulars.

## Troubleshooting

_If your lights didn't come on, here are a few things to try:_

1. Head back to WLED and check your pinout configuration under LED Preferences. Be sure the pin number is the correct GPIO for the attachment point you used.
2. Check your wiring! Be sure you connected to the IN end of the LED strip. These strips can be inconsistent so this is a pretty common problem. Use an [alligator clip](https://www.adafruit.com/product/1008) to try connecting the data wire on the other end (the power and ground wires should work from either end).
3. Try re-uploading the WLED software.&nbsp;
4. If the lights come on but you can't control them: i.e. you type in "projectname.local" into your browser and it won't connect, make sure you're on the correct WiFi network. If you're on a different network than the one you set up the sofware on, you won't see the WLED connection.
5. If your lights came on in blue or green instead of yellow, your color order is wrong. See below to fix.
6. If only half your lights came on, be sure you've got the correct number in the "length" field under LED preferences.
7. If your lights came on in a variety of weird colors and looking like a 1950s diner interior, you may have the wrong LED strip type selected. RGBW strips and RGB strips are not the same, so be sure you've got the correct strip type or you'll get very odd behavior.
8. If your microcontroller hangs or keeps rebooting, or gets really hot, you may have the power and ground lines switched. Unplug right away and check: this is a fast way to brick your controller.

# Adafruit Sparkle Motion Stick

## WLED Audioreactive Setup

The Sparkle Motion Stick comes with an onboard I2S microphone, so adding audio reactivity to your project is easy. Here's how to get it set up.

Click&nbsp; **Config** &nbsp;and then select the&nbsp; **Usermods** &nbsp;tab.

![usermods highlighted in the menu](https://cdn-learn.adafruit.com/assets/assets/000/136/524/medium640/wled_audioreactive_setup_adafruit_products_image.png?1745943834)

Scroll down a bit and you'll find the&nbsp; **AudioReactive** &nbsp;section.&nbsp;

Click the box to enable, then enter the settings and the&nbsp; **Digitalmic** &nbsp;section as follows:

- Type: **Generic I2S**
- Pin I2S SD: **13**
- Pin I2S WS:&nbsp; **12**
- Pin I2S SCK:&nbsp; **14**

The other pins are unused.

Reboot your microcontroller for changes to take effect. Unplug the board from power completely for a few seconds.

![i2s mic settings](https://cdn-learn.adafruit.com/assets/assets/000/136/994/medium640/adafruit_products_Screenshot_2025-05-16_155605.jpg?1747770392)

If you want the audio to work well in both loud and quiet settings, you may want to turn on **AGC** - automatic gain control. Start with **Normal** and then experiment with other options if you want more or less 'gain speed'.

![the AGC menu highlighted](https://cdn-learn.adafruit.com/assets/assets/000/136/525/medium640/wled_audioreactive_setup_adafruit_products_image_%281%29.png?1745944156)

There are a lot of other settings you can adjust in WLED. I found that the default settings for this mic seem to work perfectly, but you can delve into the particulars at [https://kno.wled.ge/advanced/audio-reactive/](https://kno.wled.ge/advanced/audio-reactive/)

To use audio reactive mode, head back to the main interface and select any effect that has a **music note icon** next to the name. You can also search for musical-reactive effects that are built in.

Make some noise and see how your lights react. If it doesn't work, check your pins, try turning on AGC, tapping on the mic, and rebooting (removing power completely, waiting a few seconds then turn back on).

![turning on audio reactive mode on the effect](https://cdn-learn.adafruit.com/assets/assets/000/136/526/medium640/wled_audioreactive_setup_adafruit_products_image_%282%29.png?1745944211)

If you happen to have a 2D matrix as an output, the GEQ effect shows a 'binned' frequency response graph which can be good for debugging!

![the GEQ option in the main menu](https://cdn-learn.adafruit.com/assets/assets/000/136/527/medium640/wled_audioreactive_setup_adafruit_products_image_%283%29.png?1745944285)

![a GEQ output on a 16x16 matrix](https://cdn-learn.adafruit.com/assets/assets/000/136/528/medium640/wled_audioreactive_setup_adafruit_products_IMG_2299.jpg?1745944316)

# Adafruit Sparkle Motion Stick

## WLED IR Remote Setup

Adding infrared control to your project is easy. WLED comes preprogrammed to use a variety of common IR remote controls, so you can get instant functionality with just a little bit of setup.

The Sparkle Motion Stick has an onboard IR sensor on pin 10. To use the IR receiver, you will need to install the [pre-release version of WLED (version 0.16).](https://learn.adafruit.com/adafruit-sparkle-motion-stick/wled-installation?#pre-release-version-of-wled-3198889)

![ir sensor outlined in red](https://cdn-learn.adafruit.com/assets/assets/000/136/997/medium640/adafruit_products_ir.jpg?1747770905)

Warning: To use the IR receiver, you will need to install the pre-release version of WLED (version 0.16).

## WLED IR Config
Click the&nbsp; **LED Preferences tab** &nbsp;and scroll down to&nbsp; **Hardware Setup**.

Change the IR GPIO pin to&nbsp; **10** &nbsp;and select&nbsp; **which remote** &nbsp;you're using from the dropdown.&nbsp;

![ir gpio set to 10](https://cdn-learn.adafruit.com/assets/assets/000/136/999/medium640/adafruit_products_irSettings.jpg?1747771138)

## Remote Usage: 44 Key Remote

[This 44-Key Remote is a popular option to WLED.](https://www.amazon.com/dp/B08355RHW7?th=1)

Change the brightness or turn the strip on and off with the buttons on the top row.

When you have the "solid" effect selected in WLED, the color buttons near the top of the remote will change the colors, making the pixels act like a "dumb" RGB strip.&nbsp;

On my 44-key remote, there are buttons near the bottom labeled "DIY1", "DIY2" etc. WLED will automatically assign your animation presets to these buttons so you can select your favorite presets or playlists. Simply save the presets you want to the first 6 preset slots and the buttons will pull them up.&nbsp;

Head over to the WLED wiki at [https://kno.wled.ge/](https://kno.wled.ge/) to delve into all the particulars.

# Adafruit Sparkle Motion Stick

## WLED 2D Matrix

If you're using a 2-dimensional matrix, such as an LED curtain or net, WLED has a handy 2D-matrix setup feature that will take care of the mapping for you. Head to Config and choose the **2D Configuration** tab.

Check out these tutorials for more about 2d mapping with WLED:

- [Monster Matrix](https://learn.adafruit.com/Monster-Matrix-with-WLED)
- [LED Festival Coat](https://learn.adafruit.com/led-festival-coat-with-mapping-and-wled)
- [Sound Reactive Top Hat](https://learn.adafruit.com/sound-reactive-led-top-hat)
- [Sparkle Skirt 2D](https://learn.adafruit.com/sparkle-motion-skirt-with-2d-mapping/)

Change the dropdown to read 2d Matrix, and additional options will appear. If you want to sync more than one panel, you can do it here.&nbsp;

Set up your layout numbers to match the number of rows and columns in your project. You can also change orientation here - my pixels start in the lower left corner and finish in the upper right.

![adafruit_products_2D_Set-up.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/567/medium640/adafruit_products_2D_Set-up.jpg?1707334430)

![adafruit_products_2D_Set-up_matrix.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/568/medium640/adafruit_products_2D_Set-up_matrix.jpg?1707334492)

## Matrix Effects

WLED has a hefty number of matrix effects that appear in the list when you've got your 2d matrix set up.&nbsp; Many of them can be customized with speed and intensity sliders, or different color palettes. Go wild!&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/127/569/medium800/adafruit_products_matrix_effects.jpg?1707334830)

# Adafruit Sparkle Motion Stick

## Create Presets

### Animation Presets

Once your lights are working, it's time for the fun part: creating light animations using WLED presets. This is easy and intuitive in WLED. Choose a color palette and an effect, then play with the sliders at the bottom of the Effect Mode column to customize the effect.

When you find something you like, click the +Preset button in the Presets tab and give your preset a name, then save it. You can reorder them using the "Save to ID" field.&nbsp;

You can create hundreds of presets using the preprogrammed effects, so take some time to play around and see what looks good on your LED strip.

![](https://cdn-learn.adafruit.com/assets/assets/000/131/540/medium800/led_strips_setup_presets.jpg?1722023074)

Create at least 3 presets, and be sure they are saved to ID numbers 1-3. Our next step will be to set up the switch to toggle between these presets.&nbsp;

## Control Presets

The WLED preset interface can also be used to send control commands to the LED strip. Once you've set up a button or switch, it can be used for a wide variety of control functions: change modes, change brightness, toggle the lights on and off, or a whole host of other features.&nbsp;

Each button function in WLED has 3 options: a short press, a long press, or a double press. I want my lights to cycle through presets with a short press, and to turn on or off with a long press. Here's how I set up a control preset for each of these features.

### Cycle through Presets
Click +Preset and then uncheck the "Use current state" checkbox. This will open up an API command window within the preset module.

Call the effect "Next\_FX" and type {"ps":"1~3~"} into the API command box. This tells WLED to cycle through presets 1-3. If you'd like to cycle through more presets, change the 3 to the number of presets you have.&nbsp;

Be sure your preset IDs include all the numbers -- skipping a number will break this command.

Give your preset an ID number that's above the range of your preset numbers -- I called mine 9.&nbsp;

![led_strips_presets_next_fx.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/545/medium640/led_strips_presets_next_fx.jpg?1722024741)

It's also possible to cycle between playlists. I made a playlist of sound reactive effects and a separate playlist of "standard" effects. I set up a preset that toggles between the two playlists -- effectively turning "sound reactive" mode on and off.

![led_strips_soundreactive_toggle.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/693/medium640/led_strips_soundreactive_toggle.jpg?1722904335)

### Toggle On/Off
Create another preset and call it "Toggle". Uncheck the "use current state" checkbox and enter **T=2** into the API command box. This will tell the LEDs to toggle between on and off. Save this one to ID 10.

![led_strips_presets_toggle.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/546/medium640/led_strips_presets_toggle.jpg?1722024787)

On the next page, these control presets will be connected to a button.

Find out more about creating these control presets here:&nbsp;

[https://kno.wled.ge/features/presets/](https://kno.wled.ge/features/presets/)

You can enter either JSON commands or HTTP commands into this command box, giving you a lot of control over your WLED project.&nbsp;

[https://kno.wled.ge/interfaces/json-api/](https://kno.wled.ge/interfaces/json-api/)

# Adafruit Sparkle Motion Stick

## WLED Button Setup

You can use a button in WLED to control various settings.

You can use the BOOT button, attached to GPIO 0, on the Sparkle Motion Stick.

![boot button outlined in red](https://cdn-learn.adafruit.com/assets/assets/000/136/995/medium640/adafruit_products_button.jpg?1747770550)

## Button Setup
Open up the&nbsp; **LED settings** &nbsp;screen in WLED under " **Config**". Scroll to the button setup section and set&nbsp; **button 0** &nbsp;to use pin **0** , with the type set as " **Pushbutton**".

![button menu](https://cdn-learn.adafruit.com/assets/assets/000/136/996/medium640/adafruit_products_Screenshot_2025-05-20_155122.png?1747770713)

Click **Save**. Try pressing your button and see if your effects change.&nbsp;

## Assigning to Presets

The default behavior for button 1 is to cycle through effects. However, you can change this and set up the button for any number of behaviors using the **Button Actions**.

Next, head to the **Time & Macros** config screen. Scroll down to the **Button actions area**.

![led_strips_macros.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/542/medium640/led_strips_macros.jpg?1722023424)

For your button, enter the number assigned to the your control presets.

For example, here an "advance effect" preset is number&nbsp; **22** , so **22** is setup under " **short press**". Then, a "toggle" preset is number **21** , so **21** is setup as a " **long press**". &nbsp;A "playlist toggle" to preset **20** , so a **double-click** of the button will turn sound reactive mode on or off.

![](https://cdn-learn.adafruit.com/assets/assets/000/136/923/medium640/wled_button_setup_led_strips_Cursor_and_Time_Settings.jpg?1747413651)

## Troubleshooting

If your button isn't working, here are some things to try:

1. Double check both the LED preferences page and the Time & Macros page to be sure your settings are correct, and have saved.
2. Be sure your presets are correctly numbered. WLED gets confused if the presets have non-sequential IDs (so make sure they're numbered 1, 2, 3 rather than 2, 5, 7).

# Adafruit Sparkle Motion Stick

## WLED Additional Settings

### Brightness Limiter

Find this on the LED Settings screen.

WLED automatically limits the brightness of your project so your power supply doesn't get over-taxed. The default amperage is 850mA, which is a little low for most power supplies.

For some projects, especially battery-powered projects, having the limiter turned on is a good idea. But if you're not getting the brightness you expect, try adjusting this number to match the amperage of your power supply or battery pack.

![adafruit_products_brightness_limiter.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/565/medium640/adafruit_products_brightness_limiter.jpg?1707333888)

### Access Point (AP) Mode

While you're home, it's easy to control your project over your local WiFi network. But when you're out at a festival you probably don't have WiFi access. It's still possible to connect to your project and control it using WLED's Access Point Mode.

Turn your project on and give it a minute or two to start broadcasting. Look in your WiFi networks and find **WLED-AP** - this is a mini WiFi network being broadcast by the microcontroller. Connect to it - the default password is "wled123". An instance of WLED will automatically pop up and you can control your project from anywhere.

If you're putting your lights up in public, it's a good idea to change the AP Mode default password so strangers can't log in and control your lights. This could be a security risk.

AP Mode only broadcasts for a few minutes after you boot up the board so if you don't see the WLED-AP network try rebooting.

![led_pixels_apmode.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/081/medium640/led_pixels_apmode.jpg?1711986345)

### WLED App
There are a couple different apps available to manage your WLED projects. Name and organize your projects, and find them quickly without having to type in a URL. Check the Apple or Android store for downloads.&nbsp;

My favorite is "WLED Native". It allows you to organize multiple instances and easily switch between devices without having to remember any URLs.&nbsp;

![led_pixels_wled_app.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/681/medium640/led_pixels_wled_app.jpg?1722625769)

### Backup Config & Presets
Under Config / Security & Updates you will find a place to back up your data. It's a good idea to back up your config file as soon as you're happy with the settings. Save it as a .json file on your computer. Now you can prototype and experiment to your heart's content, and if everything breaks, just re-upload this file. Or, if you're doing another build you can use this feature to copy all your settings from one board to another.

![led_pixels_backup.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/695/medium640/led_pixels_backup.jpg?1722904724)

# Adafruit Sparkle Motion Stick

## Install 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. ESP32 CircuitPython firmware is uploaded to the board via the USB serial port.

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

## Driver Install

If this is your first time using an ESP32 board on Windows or MacOS, you may need to install the USB to serial drivers. There are two options for the USB to serial chipset on your board. If you are unsure which one you have, install both drivers.

For instructions and more information regarding the CH9102F chip and driver install, please visit the [How To Install Drivers for WCH USB to Serial Chips guide](https://learn.adafruit.com/how-to-install-drivers-for-wch-usb-to-serial-chips).

For driver downloads for the CP2104 and CP2012N, please visit the [Silicon Labs Downloads page](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads).

For those running Linux, the drivers are already included.

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

Save it wherever is convenient for you.

![install_circuitpython_on_esp32_ESP32_CircuitPython_bin_downloaded.png](https://cdn-learn.adafruit.com/assets/assets/000/114/559/medium640/install_circuitpython_on_esp32_ESP32_CircuitPython_bin_downloaded.png?1661800263)

## Connecting to the Web Flasher

To begin, **plug your board into your computer via USB, using**  **a known-good data-sync cable** , directly, or via an adapter if needed.

**You will have to use the Chrome or a Chromium-based browser to install CircuitPython.** [For example, Edge and Opera are Chromium based](https://en.wikipedia.org/wiki/Chromium_(web_browser)).

Safari and Firefox, etc are _not_ supported - [they have not implemented Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Serial#browser_compatibility)!

In the **Chrome browser** visit [https://adafruit.github.io/Adafruit\_WebSerial\_ESPTool/](https://adafruit.github.io/Adafruit_WebSerial_ESPTool/)

The main page of the ESP Web Flasher should look something like this.

Note: The site now displays an alert that it is no longer maintained, and suggests using a different option. The ESP Web Flasher has still proven to be more consistent and easier to use, so it is highly suggested that you continue with this version.

![install_circuitpython_on_esp32_with_boot_button_ESPCP_web_flasher_main_page.png](https://cdn-learn.adafruit.com/assets/assets/000/114/594/medium640/install_circuitpython_on_esp32_with_boot_button_ESPCP_web_flasher_main_page.png?1661892930)

 **You should remove all other USB devices so**  **_only_ the target board is attached.** This eliminates confusion over multiple ports!

Press the&nbsp; **Connect** button in the top right of the web browser. You will get a pop up asking you to select the COM or Serial port. Look for **USB Single Serial**.

On some systems, such as MacOS, there may be additional system ports that appear in the list (as shown in the image).

![install_circuitpython_on_esp32_with_boot_button_ESPCP_connect_and_ports.png](https://cdn-learn.adafruit.com/assets/assets/000/114/595/medium640/install_circuitpython_on_esp32_with_boot_button_ESPCP_connect_and_ports.png?1661893121)

The Javascript code will now try to connect to the board. It may timeout for a bit until it succeeds. On success, you will see that it is **Connected** &nbsp;and will print out a unique&nbsp; **MAC address** identifying the board along with other information that was detected.

![install_circuitpython_on_esp32_with_boot_button_ESPCP_flasher_connection_success.png](https://cdn-learn.adafruit.com/assets/assets/000/114/596/medium640/install_circuitpython_on_esp32_with_boot_button_ESPCP_flasher_connection_success.png?1661893862)

Once you have successfully connected, the command toolbar will appear.

![install_circuitpython_on_esp32_with_boot_button_ESPCP_command_tool_bar.png](https://cdn-learn.adafruit.com/assets/assets/000/114/597/medium640/install_circuitpython_on_esp32_with_boot_button_ESPCP_command_tool_bar.png?1661893964)

## Erasing the Board Contents

If you would like to erase the entire flash area so that you can start with a clean slate, you can use the erase feature. We recommend doing this every time before installing or updating CircuitPython.

To erase the contents, click the **Erase** button. You will be prompted as to whether you want to continue. Click **OK** to continue. If you do not wish to continue, click Cancel.

![install_circuitpython_on_esp32_ESPCP_click_erase_ok.png](https://cdn-learn.adafruit.com/assets/assets/000/114/630/medium640/install_circuitpython_on_esp32_ESPCP_click_erase_ok.png?1661976027)

You'll see "Erasing flash memory. Please wait..." This will eventually be followed by "Finished." and the amount of time it took to erase.

**Do not disconnect!** Immediately continue on to Programming the Board.

![install_circuitpython_on_esp32_ESPCP_erase_finished.png](https://cdn-learn.adafruit.com/assets/assets/000/114/632/medium640/install_circuitpython_on_esp32_ESPCP_erase_finished.png?1661976226)

Warning: 

## Programming the Board
You can click on **Choose a file...** from any of the available buttons. It will only attempt to program buttons with a file and a unique location. Select the&nbsp; **.bin** file you downloaded at the beginning of this page from the file chooser dialogue.

Verify that the **Offset** box next to the file location you used is 0x0. The offset defaults to 0x0, so unless you changed it manually, it should be good to go.

![install_circuitpython_on_esp32_ESPCP_choose_a_file.png](https://cdn-learn.adafruit.com/assets/assets/000/114/633/medium640/install_circuitpython_on_esp32_ESPCP_choose_a_file.png?1661976639)

![install_circuitpython_on_esp32_ESPCP_bin_to_upload.png](https://cdn-learn.adafruit.com/assets/assets/000/114/669/medium640/install_circuitpython_on_esp32_ESPCP_bin_to_upload.png?1661979129)

Once you choose a file, the button text will change to match your filename. You can then click the **Program** button to start flashing.

![install_circuitpython_on_esp32_ESPCP_bin_loaded_press_program.png](https://cdn-learn.adafruit.com/assets/assets/000/114/655/medium640/install_circuitpython_on_esp32_ESPCP_bin_loaded_press_program.png?1661978037)

A progress bar will appear and after a minute or two, you will have written the firmware.

![install_circuitpython_on_esp32_ESPCP_programming_the_bin.png](https://cdn-learn.adafruit.com/assets/assets/000/114/656/medium640/install_circuitpython_on_esp32_ESPCP_programming_the_bin.png?1661978267)

You've now successfully programmed CircuitPython onto your board! As suggested in the output, press reset to run the new firmware.

![install_circuitpython_on_esp32_ESPCP_programming_complete.png](https://cdn-learn.adafruit.com/assets/assets/000/114/668/medium640/install_circuitpython_on_esp32_ESPCP_programming_complete.png?1661978790)

As the ESP32 does not have native USB, no USB drive will show up on your computer when you reset. With CircuitPython firmware loaded, the REPL can be accessed over a serial/COM port.

For more details on installation, how to configure your ESP32, and info on getting started with CircuitPython on your ESP32 using the Web Workflow, check out the [CircuitPython on ESP32 Quick Start guide](https://learn.adafruit.com/circuitpython-with-esp32-quick-start).

# Adafruit Sparkle Motion Stick

## Connecting to the USB Workflow Code Editor

Warning: The USB workflow is a new feature and there may be bugs! If you find a bug, please [file an issue on GitHub](https://github.com/circuitpython/web-editor/issues).

To use the Code Editor, you will need an internet browser such as Google Chrome or Microsoft Edge. It's possible that it may work in other browsers as well, but these have been more thoroughly tested.

Open your browser and navigate to [https://code.circuitpython.org/](https://code.circuitpython.org/). Select **USB** on the dialog prompt that comes up.

![circuitpython_Screenshot_2024-07-01_at_10.27.14_AM.png](https://cdn-learn.adafruit.com/assets/assets/000/130/966/medium640/circuitpython_Screenshot_2024-07-01_at_10.27.14_AM.png?1719854918)

This will display a page of instructions along with a **button** to bring up a list of devices to connect to.

Click **Connect to Device** and then **select your board** in the pop-up window. Click **Connect** to connect your board to the editor.

![circuitpython_Screenshot_2024-07-01_at_10.29.39_AM.png](https://cdn-learn.adafruit.com/assets/assets/000/130/967/medium640/circuitpython_Screenshot_2024-07-01_at_10.29.39_AM.png?1719855227)

![circuitpython_Screenshot_2024-07-01_at_10.38.48_AM.png](https://cdn-learn.adafruit.com/assets/assets/000/130/970/medium640/circuitpython_Screenshot_2024-07-01_at_10.38.48_AM.png?1719855548)

Once you have connected, the **Connect** button in the upper right-hand corner should change to a **Disconnect** button.

![wireless_Disconnect_Button.png](https://cdn-learn.adafruit.com/assets/assets/000/114/892/medium640/wireless_Disconnect_Button.png?1662672956)

# Adafruit Sparkle Motion Stick

## Usage

## Opening and Saving Files

Opening and Saving files is designed to be like to most other applications.&nbsp;Just use the buttons along the top of the editor window.

Clicking the **Open** or&nbsp; **Save As** buttons along the top will open the File Dialog. Clicking the **Save + Run** button will save your file and run the code. If your file hasn't been saved yet, this will also bring up the file dialog box.

![wireless_Screenshot_2024-07-02_at_8.46.57_AM.png](https://cdn-learn.adafruit.com/assets/assets/000/130/980/medium640/wireless_Screenshot_2024-07-02_at_8.46.57_AM.png?1719935356)

The file dialog that appears is a simplified dialog that displays the current path at the top, allows you to navigate through the file tree to select the file you would like to open, and has buttons on the bottom to open or save the file you would like to use.

Canceling will tell the editor that you do not want to continue with the current operation.

![wireless_File_dialog.png](https://cdn-learn.adafruit.com/assets/assets/000/115/953/medium640/wireless_File_dialog.png?1666046715)

The X at the top performs the same function as the Cancel button as does clicking outside of the dialog.

On the Save As dialog, you can also type in a filename in the field next to the button.

![wireless_File_dialog_2.png](https://cdn-learn.adafruit.com/assets/assets/000/115/954/medium640/wireless_File_dialog_2.png?1666046738)

## Running Code

As mentioned above, the&nbsp; **Save + Run** button will first save your file, then run the code. The logic to run the code however is currently very simplistic in that it will try a couple of basic strategies to run your code, but doesn't currently do much beyond that.

The way it works is if you are working on **code.py** in the root folder, a soft reset will be performed, which automatically runs **code.py**. If you were working on some code in another file, the editor will attempt to perform an import on this code, which should run it. When you run your code, it will automatically switch over to the serial terminal.

Click the **Save + Run** &nbsp;button to save and run the code current code.

![wireless_Save_and_Run.png](https://cdn-learn.adafruit.com/assets/assets/000/114/853/medium640/wireless_Save_and_Run.png?1662509114)

## File Dialog Toolbar

The file Dialog toolbar along the top allows you to perform common operations on files and folders regardless of whether you are saving or opening. Clicking the cancel button at the bottom will not undo any operations that were performed with these buttons.

### Renaming and Deleting Files and Folders

You can rename or delete both files and folders. An item must be selected first for the buttons to become available.

Use the **delete** and **rename** buttons here to perform the corresponding operation on the currently selected file or folder.

![wireless_Delete_and_Rename.png](https://cdn-learn.adafruit.com/assets/assets/000/115/955/medium640/wireless_Delete_and_Rename.png?1666047250)

### Creating New Folders

This feature allows you to create a new folder to store your work inside of.

Clicking the **new folder** button at the top will prompt you for a folder name. It will inform you of invalid folder names such as the same name as an existing file or folder or a folder that begins with a period.

![wireless_New_Folder.png](https://cdn-learn.adafruit.com/assets/assets/000/115/956/medium640/wireless_New_Folder.png?1666047276)

![wireless_New_Folder_Prompt.png](https://cdn-learn.adafruit.com/assets/assets/000/115/957/medium640/wireless_New_Folder_Prompt.png?1666047296)

### Uploading and Downloading Files and Folders

This feature allows you to upload or download files as long as they fit in the available space. If you need to add images or sound files for your project, you can use the upload button to add them. If you need to retrieve a file from your device for whatever reason, the download button will give you access to do that.

You can also download folders. When you select a folder and click download, the contents of that folder are automatically zipped into a single file. If nothing is selected when you click the download button, the current folder will be used.

Use the **upload** or **download** buttons to easily add files or retrieve them from your board.

![wireless_Upload_and_Download.png](https://cdn-learn.adafruit.com/assets/assets/000/115/958/medium640/wireless_Upload_and_Download.png?1666047325)

### Moving Files and Folders

This feature allows you to move files and folders to a different location on the device. When you click the move button, another prompt will appear on top of the dialog that allows you to navigate to where you would like to move the currently selected item.&nbsp;

Use the **move** button to move files or folders to a new location on the device.

The second dialog that appears will show only folders and allow you to navigate to where you would like to move the file.

![wireless_Move_Item.png](https://cdn-learn.adafruit.com/assets/assets/000/115/959/medium640/wireless_Move_Item.png?1666047519)

![wireless_Move_Item_Prompt.png](https://cdn-learn.adafruit.com/assets/assets/000/115/960/medium640/wireless_Move_Item_Prompt.png?1666047536)

## Using the Serial Terminal
The serial terminal allows you to watch the output of your device as well as type inputs just like you can from a separate application like PuTTY, except there's nothing you need to configure. This allows you to access the REPL or view the output of your currently running code.

Use the mode buttons in the bottom left-hand corner to open and close the serial and editor panes.

![wireless_Screenshot_2024-07-03_at_8.08.00_AM.png](https://cdn-learn.adafruit.com/assets/assets/000/131/075/medium640/wireless_Screenshot_2024-07-03_at_8.08.00_AM.png?1720019348)

## More Features to Come

The CircuitPython Code Editor is still under development, so expect more features to be added. If you would like to contribute [on GitHub](https://github.com/circuitpython/web-editor/), you can submit any new issues or pull requests for review.

# Adafruit Sparkle Motion Stick

## Blink

In learning any programming language, you often begin with some sort of `Hello, World!` program. In CircuitPython, Hello, World! is blinking an LED. Blink is one of the simplest programs in CircuitPython. It involves three built-in modules, two lines of set up, and a short loop. Despite its simplicity, it shows you many of the basic concepts needed for most CircuitPython programs, and provides a solid basis for more complex projects. Time to get blinky!

## LED Location
![Sparkle Motion Stick illustration with red LED in the corner of the board near the IR receiver and USB connector highlighted.](https://cdn-learn.adafruit.com/assets/assets/000/136/932/medium800/adafruit_products_blink_led_highlight.png?1747663764 )

## Blinking an LED

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **CircuitPython\_Templates/blink/** and then click on the directory that matches the version of CircuitPython you're using.

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

In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![blink_upload.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/893/medium640/blink_upload.jpg?1724077429)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![blink_code_dot_py.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/894/medium640/blink_code_dot_py.jpg?1724077767)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![blink_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/895/medium640/blink_overwrite.jpg?1724077804)

You'll see a new **code.py** file appear in the file browser. **Select it** and click **Open** to view it in the code editor.

![blink_openCode.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/896/medium640/blink_openCode.jpg?1724077840)

You'll see the LED blink **code.py** file contents. Click **Restart** above the Serial monitor to run the LED blink code.

![](https://cdn-learn.adafruit.com/assets/assets/000/131/897/medium800/blink_restartCode.jpg?1724077902)

The built-in LED begins blinking!

Note that the code is a little less "Pythonic" than it could be. It could also be written as `led.value = not led.value` with a single `time.sleep(0.5)`. That way is more difficult to understand if you're new to programming, so the example is a bit longer than it needed to be to make it easier to read.

It's important to understand what is going on in this program.

First you `import` three modules: `time`, `board` and `digitalio`. This makes these modules available for use in your code. All three are built-in to CircuitPython, so you don't need to download anything to get started.

Next, you set up the LED. To interact with hardware in CircuitPython, your code must let the board know where to look for the hardware and what to do with it. So, you create a `digitalio.DigitalInOut()` object, provide it the LED pin using the `board` module, and save it to the variable `led`. Then, you tell the pin to act as an `OUTPUT`.

Finally, you create a `while True:` loop. This means all the code inside the loop will repeat indefinitely. Inside the loop, you set `led.value = True` which powers on the LED. Then, you use `time.sleep(0.5)` to tell the code to wait half a second before moving on to the next line. The next line sets `led.value = False` which turns the LED off. Then you use another `time.sleep(0.5)` to wait half a second before starting the loop over again.

With only a small update, you can control the blink speed. The blink speed is controlled by the amount of time you tell the code to wait before moving on using `time.sleep()`. The example uses `0.5`, which is one half of one second. Try increasing or decreasing these values to see how the blinking changes.

That's all there is to blinking an LED using CircuitPython!

# Adafruit Sparkle Motion Stick

## Digital Input

The CircuitPython `digitalio` module has many applications. The basic Blink program sets up the LED as a digital output. You can just as easily set up a **digital input** such as a button to control the LED. This example builds on the basic Blink example, but now includes setup for a button switch. Instead of using the `time` module to blink the LED, it uses the status of the button switch to control whether the LED is turned on or off.

## LED and Button
![Sparkle Motion Stick illustration with red LED in the corner of the board near the IR receiver and USB connector, and the button in the center of the board highlighted](https://cdn-learn.adafruit.com/assets/assets/000/136/933/medium800/adafruit_products_digitalio_led_btn_highlight.png?1747664160 )

## Controlling the LED with a Button

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **CircuitPython\_Templates/digital\_input\_built\_in\_button\_led/** and then click on the directory that matches the version of CircuitPython you're using.

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

In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![digital_input___little_led_and_button_upload.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/899/medium640/digital_input___little_led_and_button_upload.jpg?1724078447)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![digital_input___little_led_and_button_code_dot_py.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/900/medium640/digital_input___little_led_and_button_code_dot_py.jpg?1724078473)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![digital_input___little_led_and_button_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/901/medium640/digital_input___little_led_and_button_overwrite.jpg?1724078490)

You'll see a new **code.py** file appear in the file browser. **Select it** and click **Open** to view it in the code editor.

![digital_input___little_led_and_button_openCode.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/902/medium640/digital_input___little_led_and_button_openCode.jpg?1724078507)

You'll see the digital input **code.py** file contents. Click **Restart** above the Serial monitor to run the digital input code.

![](https://cdn-learn.adafruit.com/assets/assets/000/131/903/medium800/digital_input___little_led_and_button_digiRestart.jpg?1724078690)

Now, press the button. The LED lights up! Let go of the button and the LED turns off.

![Sparkle Motion Stick running digitalio example code. The onboard button is pressed and the built-in LED lights up.](https://cdn-learn.adafruit.com/assets/assets/000/136/934/medium800thumb/adafruit_products_digitalio_led_btn.jpg?1747666226 )

Note that the code is a little less "Pythonic" than it could be. It could also be written as `led.value = not button.value`. That way is more difficult to understand if you're new to programming, so the example is a bit longer than it needed to be to make it easier to read.

First you `import` two modules: `board` and `digitalio`. This makes these modules available for use in your code. Both are built-in to CircuitPython, so you don't need to download anything to get started.

Next, you set up the LED. To interact with hardware in CircuitPython, your code must let the board know where to look for the hardware and what to do with it. So, you create a `digitalio.DigitalInOut()` object, provide it the LED pin using the `board` module, and save it to the variable `led`. Then, you tell the pin to act as an `OUTPUT`.

You include setup for the button as well. It is similar to the LED setup, except the button is an `INPUT`, and requires a pull up.

Inside the loop, you check to see if the button is pressed, and if so, turn on the LED. Otherwise the LED is off.

That's all there is to controlling an LED with a button switch!

# Adafruit Sparkle Motion Stick

## Built-In NeoPixel

Your board has a built-in RGB NeoPixel status LED. You can use CircuitPython code to control the color and brightness of this LED. It is also used to indicate the bootloader status and errors in your CircuitPython code.

A NeoPixel is what Adafruit calls the WS281x family of addressable RGB LEDs. It contains three LEDs - a red one, a green one and a blue one - along side a driver chip in a tiny package controlled by a single pin. They can be used individually (as in the built-in LED on your board), or chained together in strips or other creative form factors. NeoPixels do not light up on their own; they require a microcontroller. So, it's super convenient that the NeoPixel is built in to your microcontroller board!

This page will cover using CircuitPython to control the status RGB NeoPixel built into your microcontroller. You'll learn how to change the color and brightness, and how to make a rainbow. Time to get started!

## NeoPixel Location
![Sparkle Motion Stick Illustration with built-in neopixel, near the IR receiver and built-in button, highlighted.](https://cdn-learn.adafruit.com/assets/assets/000/136/935/medium800/adafruit_products_neopixel_highlight.png?1747667827 )

## NeoPixel Color and Brightness

To use with CircuitPython, you need to first install a few libraries, into the **lib** folder on your board. Then you need to update **code.py** with the example script.

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **CircuitPython\_Templates/status\_led\_one\_neopixel\_rgb/** and then click on the directory that matches the version of CircuitPython you're using.

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

## Update the **/lib** Folder
In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Folders**.

![built_in_neopixel_uploadFolders.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/912/medium640/built_in_neopixel_uploadFolders.jpg?1724082553)

Navigate to the project bundle that you downloaded and select the **/lib folder**.

![built_in_neopixel_uploadLib.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/913/medium640/built_in_neopixel_uploadLib.jpg?1724082575)

You'll be asked if you want to upload the **/lib** folder from the&nbsp;Project Bundle. Click **Upload**.

![built_in_neopixel_confirmUploadNeo.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/914/medium640/built_in_neopixel_confirmUploadNeo.jpg?1724082591)

After the upload finishes, you can open the **lib** folder to view the two library files required for the NeoPixel examples.

![built_in_neopixel_updatedLibNeo.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/915/medium640/built_in_neopixel_updatedLibNeo.jpg?1724082622)

## Update **code.py**
In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![built_in_neopixel_upload.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/909/medium640/built_in_neopixel_upload.jpg?1724082434)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![built_in_neopixel_code_dot_py.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/910/medium640/built_in_neopixel_code_dot_py.jpg?1724082449)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![built_in_neopixel_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/911/medium640/built_in_neopixel_overwrite.jpg?1724082469)

The built-in NeoPixel begins blinking red, then green, then blue, and repeats!

![Sparkle Motion Stick running the neopixel RGB example with it's built-in neopixel changing between red, green, and blue](https://cdn-learn.adafruit.com/assets/assets/000/136/936/medium800thumb/adafruit_products_neopixel_rgb.jpg?1747669857 )

First you import two modules, `time` and `board`, and one library, `neopixel`. This makes these modules and libraries available for use in your code. The first two are modules built-in to CircuitPython, so you don't need to download anything to use those. The `neopixel` library is separate, which is why you needed to install it before getting started.

Next, you set up the NeoPixel LED. To interact with hardware in CircuitPython, your code must let the board know where to look for the hardware and what to do with it. So, you create a `neopixel.NeoPixel()` object, provide it the NeoPixel LED pin using the `board` module, and tell it the number of LEDs. You save this object to the variable `pixel`.

Then, you set the NeoPixel brightness using the `brightness` attribute. `brightness` expects float between `0` and `1.0`. A _float_ is essentially a number with a decimal in it. The brightness value represents a percentage of maximum brightness; `0` is 0% and `1.0` is 100%. Therefore, setting `pixel.brightness = 0.3` sets the brightness to 30%. The default brightness, which is to say the brightness if you don't explicitly set it, is `1.0`. The default is really bright! That is why there is an option available to easily change the brightness.

Inside the loop, you turn the NeoPixel red for 0.5 seconds, green for 0.5 seconds, and blue for 0.5 seconds.

To turn the NeoPixel red, you "fill" it with an RGB value. Check out the section below for details on RGB colors. The RGB value for red is `(255, 0, 0)`. Note that the RGB value includes the parentheses. The `fill()` attribute expects the full RGB value including those parentheses. That is why there are two pairs of parentheses in the code.

You can change the RGB values to change the colors that the NeoPixel cycles through. Check out the list below for some examples. You can make any color of the rainbow with the right RGB value combination!

That's all there is to changing the color and setting the brightness of the built-in NeoPixel LED!

## RGB LED Colors

RGB LED colors are set using a combination of&nbsp; **r** ed, **g** reen, and **b** lue, in the form of an ( **R** ,&nbsp; **G** , **B** ) tuple. Each member of the tuple is set to a number between 0 and 255 that determines the amount of each color present. Red, green and blue in different combinations can create all the colors in the rainbow! So, for example, to set an LED to red, the tuple would be `(255, 0, 0)`, which has the maximum level of red, and no green or blue. Green would be `(0, 255, 0)`, etc. For the colors between, you set a combination, such as cyan which is `(0, 255, 255)`, with equal amounts of green and blue. If you increase all values to the same level, you get white! If you decrease all the values to 0, you turn the LED off.

Common colors include:

- red: `(255, 0, 0)`
- green: `(0, 255, 0)`
- blue: `(0, 0, 255)`
- cyan: `(0, 255, 255)`
- purple: `(255, 0, 255)`
- yellow: `(255, 255, 0)`
- white: `(255, 255, 255)`
- black (off): `(0, 0, 0)`

## NeoPixel Rainbow

You should have already installed the library necessary to use the built-in NeoPixel LED. If not, follow the steps at the beginning of the NeoPixel Color and Brightness section to install it.

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **CircuitPython\_Templates/status\_led\_one\_neopixel\_rainbow/** and then click on the directory that matches the version of CircuitPython you're using.

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

Update the **code.py** file in the USB code editor with the rainbow **code.py** file. The same libraries from the RGB blinking example are used. The NeoPixel displays a rainbow cycle!

![Sparkle Motion Stick running the neopixel RGB example with it's built-in neopixel sweeping between all of the colors of the rainbow](https://cdn-learn.adafruit.com/assets/assets/000/136/937/medium800thumb/adafruit_products_neopixel_rainbow.jpg?1747670238 )

This example builds on the previous example.

First, you import the same three modules and libraries. In addition to those, you import `colorwheel`.

The NeoPixel hardware setup and brightness setting are the same.

Next, you have the `rainbow()` helper function. This helper displays the rainbow cycle. It expects a `delay` in seconds. The higher the number of seconds provided for `delay`, the slower the rainbow will cycle. The helper cycles through the values of the color wheel to create a rainbow of colors.

Inside the loop, you call the rainbow helper with a 0.2 second delay, by including `rainbow(0.2)`.

That's all there is to making rainbows using the built-in NeoPixel LED!

# Adafruit Sparkle Motion Stick

## Sparkle Motion NeoPixel Demo

![Sparkle Motion Stick running the led_animations example with two strips showing a rainbow, and comet animations respectively](https://cdn-learn.adafruit.com/assets/assets/000/136/972/medium800thumb/adafruit_products_sparkle_stick_multi_animations.jpg?1747752620 )

The main use of the Sparkle Motion Stick is lighting up RGB LEDs to dazzle and delight. CircuitPython has the [Adafruit\_CircuitPython\_Neopixel](https://github.com/adafruit/Adafruit_CircuitPython_Neopixel) module, which allows you to easily write Python code that lets you control NeoPixels, as well as the [Adafruit\_CircuitPython\_LED\_Animation](https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation) module that provides more advanced control with an assortment of fun and colorful animations. In the example below, you'll run two different LED animations on two strips of NeoPixels at the same time.&nbsp;

## Wiring
NeoPixels

- **terminal block -** to **GND** on one NeoPixel strip. (black wire)
- **terminal block +** to **5V** on one NeoPixel strip. (red wire)
- **GND** on one NeoPixel strip to **GND** on the other NeoPixel strip (black wire)
- **5V** on one NeoPixel strip to **5V** on the other NeoPixel strip (red wire)
- **terminal block 21** to **DIN** on the first NeoPixel strip. (orange wire)
- **terminal block 22** to **DIN** on the second NeoPixel strip. (yellow wire)

![Sparkle Motion Stick Illustration with wiring diagram depicing the connections for the led aniatmion demo with 2 NeoPixel strips.](https://cdn-learn.adafruit.com/assets/assets/000/136/940/medium640/adafruit_products_led_animation_multistrip.png?1747677344)

## CircuitPython Usage

To use with CircuitPython, you need to first install a few libraries, into the **lib** folder on your board. Then you need to update **code.py** with the example script.

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **Sparkle\_Motion\_Examples/CircuitPython\_Sparkle\_Motion\_Neopixel\_Animation/** and then click on the directory that matches the version of CircuitPython you're using.

## Example Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Sparkle_Motion_Examples/CircuitPython_Sparkle_Motion_Neopixel_Animation/code.py

## Update the **/lib** Folder
In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Folders**.

![adafruit_products_built_in_neopixel_uploadFolders.png](https://cdn-learn.adafruit.com/assets/assets/000/134/818/medium640/adafruit_products_built_in_neopixel_uploadFolders.png?1738000041)

Navigate to the project bundle that you downloaded and select the **/lib** folder.

![adafruit_products_built_in_neopixel_uploadLib.png](https://cdn-learn.adafruit.com/assets/assets/000/134/819/medium640/adafruit_products_built_in_neopixel_uploadLib.png?1738000084)

You'll be asked if you want to upload the **/lib** folder from the&nbsp;Project Bundle. Click **Upload**.

![adafruit_products_built_in_neopixel_confirmUploadNeo.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/820/medium640/adafruit_products_built_in_neopixel_confirmUploadNeo.jpg?1738000139)

After the upload finishes, you can open the **lib** folder to view the two library files required for the NeoPixel examples.

Your&nbsp; **CIRCUITPY/lib** &nbsp;folder should contain the following folders:

- **adafruit\_led\_animation/**
- **adafruit\_pixelbuf.mpy**
- **neopixel.mpy**

![adafruit_products_neopixel_animation_libs.png](https://cdn-learn.adafruit.com/assets/assets/000/134/821/medium640/adafruit_products_neopixel_animation_libs.png?1738000174)

In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![adafruit_products_blink_upload.png](https://cdn-learn.adafruit.com/assets/assets/000/134/822/medium640/adafruit_products_blink_upload.png?1738000226)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![adafruit_products_blink_code_dot_py.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/878/medium640/adafruit_products_blink_code_dot_py.jpg?1738087071)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![adafruit_products_blink_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/879/medium640/adafruit_products_blink_overwrite.jpg?1738087111)

This example utilizes both of the NeoPixel outputs on terminal blocks `D21` and `D22`. It starts by initializing variables for the pixel pins and count of how many NeoPixels are in each strip. Next it creates instances of `neopixel.NeoPixel` for each strip. Then it creates a `Comet` animation on one strip, and a `Rainbow` animation on the other. Inside of the main `while True:` each animation object has it's `animate()` function called to advance it by one step.

# Adafruit Sparkle Motion Stick

## CircuitPython IR Remote

![Sparkle Motion Stick running the IR remote example code, buttons on the remote are pressed changing the color and brightness of the NeoPixel strip that is connected.](https://cdn-learn.adafruit.com/assets/assets/000/136/979/medium800thumb/adafruit_products_ir_remote.jpg?1747773805 )

The Adafruit Sparkle Motion Stick has an IR Receiver built-in for all of your remote controlling needs. The [Adafruit CircuitPython IRRemote](https://github.com/adafruit/Adafruit_CircuitPython_IRRemote) library makes it easy to decode the signals sent to the receiver. This example will get you started by demonstrating how to use one of our [mini remote controls](https://www.adafruit.com/product/389) to change the color and brightness of a connected strip of NeoPixels.

## IR Receiver & NeoPixel Output Location
![Sparkle Motion Stick with IR Reciever and NeoPixel output terminal 21 highlighted along with output terminals for GND and 5V](https://cdn-learn.adafruit.com/assets/assets/000/136/974/medium800/adafruit_products_sparkle_multianimation_highlights.png?1747753300 )

The IR Receiver is connected with the pin alias `board.IR`. This example assumes the NeoPixel strip will be plugged in to the terminal blocks for pin `board.D21`.

## Necessary Hardware

You can use any IR remote with basic NEC codes that are supported by the [Adafruit CircuitPython IRRemote](https://github.com/adafruit/Adafruit_CircuitPython_IRRemote) library, and any NeoPixel strip that you like. The following items are the ones depicted on this page.

### NeoPixel Stick - 8 x 5050 RGB LED with Integrated Drivers

[NeoPixel Stick - 8 x 5050 RGB LED with Integrated Drivers](https://www.adafruit.com/product/1426)
Make your own little LED strip arrangement with this stick of NeoPixel LEDs. We crammed 8 of the tiny 5050 (5mm x 5mm) smart RGB LEDs onto a PCB with mounting holes and a chainable design. Use only one microcontroller pin to control as many as you can chain together! Each LED is addressable as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1426)
[Related Guides to the Product](https://learn.adafruit.com/products/1426/guides)
![NeoPixel Stick with 8 x 5050 RGB LED ](https://cdn-shop.adafruit.com/640x480/1426-05.jpg)

### Mini Remote Control

[Mini Remote Control](https://www.adafruit.com/product/389)
This little remote control would be handy for controlling a robot or other project from across the room. It has 21 buttons and a layout we thought was handy: directional buttons and number entry buttons. The remote uses the NEC encoding type and sends data codes 0 thru 26 (it skips #3, #7,...

In Stock
[Buy Now](https://www.adafruit.com/product/389)
[Related Guides to the Product](https://learn.adafruit.com/products/389/guides)
![Mini Remote Control with 21 buttons](https://cdn-shop.adafruit.com/640x480/389-03.jpg)

## Wiring
NeoPixels

- **terminal block -** to **GND** on the NeoPixel strip. (black wire)
- **terminal block +** to **5V** on the NeoPixel strip. (red wire)
- **terminal block 21** to **DIN** on the NeoPixel strip. (green wire)

![Sparkle Motion Stick illustration with wiring diagram showing connections from the GND, 5V, and NeoPixel output pin 21 terminals to an 8x1 NeoPixel strip.](https://cdn-learn.adafruit.com/assets/assets/000/136/975/medium640/adafruit_products_ir_remote_fritzing.png?1747753641)

## CircuitPython Usage

To use with CircuitPython, you need to first install a few libraries, into the **lib** folder on your board. Then you need to update **code.py** with the example script.

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **Sparkle\_Motion\_Examples/CircuitPython\_Sparkle\_Motion\_IR\_Remote/** and then click on the directory that matches the version of CircuitPython you're using.

## Example Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Sparkle_Motion_Examples/CircuitPython_Sparkle_Motion_IR_Remote/code.py

## Update the **/lib** Folder
In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Folders**.

![adafruit_products_built_in_neopixel_uploadFolders.png](https://cdn-learn.adafruit.com/assets/assets/000/134/911/medium640/adafruit_products_built_in_neopixel_uploadFolders.png?1738164789)

Navigate to the project bundle that you downloaded and select the&nbsp; **/lib** folder.

![adafruit_products_ir_remote_upload_libs.png](https://cdn-learn.adafruit.com/assets/assets/000/134/923/medium640/adafruit_products_ir_remote_upload_libs.png?1738181155)

You'll be asked if you want to upload the&nbsp; **/lib** folder from the&nbsp;Project Bundle. Click **Upload**.

![adafruit_products_ir_remote_upload_libs_2.png](https://cdn-learn.adafruit.com/assets/assets/000/134/924/medium640/adafruit_products_ir_remote_upload_libs_2.png?1738181372)

After the upload finishes, you can open the **lib** folder to view the two library files required for the NeoPixel examples.

Your&nbsp; **CIRCUITPY/lib** &nbsp;folder should contain the following folders:

- **adafruit\_irremote.mpy**
- **adafruit\_pixelbuf.mpy**
- **neopixel.mpy**

![adafruit_products_ir_remote_after_upload_libs.png](https://cdn-learn.adafruit.com/assets/assets/000/134/925/medium640/adafruit_products_ir_remote_after_upload_libs.png?1738181505)

In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![adafruit_products_blink_upload.png](https://cdn-learn.adafruit.com/assets/assets/000/134/926/medium640/adafruit_products_blink_upload.png?1738181559)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![adafruit_products_ir_remote_upload_code.png](https://cdn-learn.adafruit.com/assets/assets/000/134/927/medium640/adafruit_products_ir_remote_upload_code.png?1738181674)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![adafruit_products_blink_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/134/928/medium640/adafruit_products_blink_overwrite.jpg?1738181736)

This example utilizes the NeoPixel output terminal blocks for pin `D21`. It starts by initializing `PulseIn` and the IR Decoder instance. Then the NeoPixel instance. Inside of the main `while True:` loop it reads any incoming messages from the decoder. When the up or down commands are received it raises or lowers the brightness of the NeoPixels, when the right or left commands are received it changes the color of the NeoPixels.

# Adafruit Sparkle Motion Stick

## WiFi Test

In this example, you'll test your Sparkle Motion Stick WiFi connection by connecting to your SSID, printing your MAC address and IP address to the REPL and then pinging Google.

## **settings.toml** File

If you've worked on WiFi projects with CircuitPython before, you're probably familiar with the **secrets.py** file. This file is a Python file that is stored on your **CIRCUITPY** drive that contains all of your secret WiFi information, such as your SSID, SSID password and any API keys for IoT services.&nbsp;

As of [CircuitPython 8](https://circuitpython.org/downloads), there is support for a **settings.toml** file. Similar to **secrets.py** , the **settings.toml** file separates your sensitive information from your main **code.py** file.

Warning: Your settings.toml file should be stored in the main directory of your board. It should not be in a folder.

## **settings.toml&nbsp;** File Example

Here is an example on how to format your&nbsp; **settings.toml** &nbsp;file.

```auto
# Comments are supported
CIRCUITPY_WIFI_SSID="guest wifi"
CIRCUITPY_WIFI_PASSWORD="guessable"
CIRCUITPY_WEB_API_PORT=80
CIRCUITPY_WEB_API_PASSWORD="passw0rd"
test_variable="this is a test"
thumbs_up="\U0001f44d"
```

In a&nbsp; **settings.toml** &nbsp;file, it's important to keep these factors in mind:

- Strings are wrapped in double quotes; ex:&nbsp;`"your-string-here"`
- Integers are&nbsp;_ **not** _&nbsp;quoted and may be written in decimal with optional sign (`+1`,&nbsp;`-1`,&nbsp;`1000`) or hexadecimal (`0xabcd`).
  - Floats, octal (`0o567`) and binary (`0b11011`) are not supported.

- Use&nbsp;`\u`&nbsp;escapes for weird characters,&nbsp;`\x`&nbsp;and&nbsp;`\ooo`&nbsp;escapes are not available in&nbsp; **.toml** &nbsp;files
  - Example:&nbsp;`\U0001f44d`&nbsp;for 👍 (thumbs up emoji) and&nbsp;`\u20ac`&nbsp;for € (EUR sign)

- Unicode emoji, and non-ASCII characters, stand for themselves as long as you're careful to save in "UTF-8 without BOM" format

When your&nbsp; **settings.toml&nbsp;** file is ready, you can save it in your text editor with the&nbsp; **.toml** &nbsp;extension.

![circuitpython_internet_test___settings_toml_adafruit_products_dotToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/122/208/medium640/circuitpython_internet_test___settings_toml_adafruit_products_dotToml.jpg?1688042031)

## CircuitPython WiFi Example
In the example below, click the **Download Project Bundle** button below to download the&nbsp; **code.py** file in a zip file. Extract the contents of the zip file and then click on the directory that matches the version of CircuitPython you're using.

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

In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![circuitpython_internet_test___settings_toml_upload.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/916/medium640/circuitpython_internet_test___settings_toml_upload.jpg?1724083097)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![circuitpython_internet_test___settings_toml_code_dot_py.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/917/medium640/circuitpython_internet_test___settings_toml_code_dot_py.jpg?1724083117)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![circuitpython_internet_test___settings_toml_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/918/medium640/circuitpython_internet_test___settings_toml_overwrite.jpg?1724083133)

## Update Your **settings.toml** File

Remember to add your **settings.toml** file as described earlier in this page. You'll need to include your `CIRCUITPY_WIFI_SSID` and `CIRCUITPY_WIFI_PASSWORD` in the file.&nbsp;

You can edit the file manually in the USB code editor by clicking **Open** , selecting **settings.toml** and clicking **Open** at the bottom of the dialog box.

![circuitpython_internet_test___settings_toml_openSettingsDotToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/919/medium640/circuitpython_internet_test___settings_toml_openSettingsDotToml.jpg?1724083258)

With **settings.toml** open in the editor, you can add your WiFi credentials:

`CIRCUITPY_WIFI_SSID = "your-ssid-here"`  
`CIRCUITPY_WIFI_PASSWORD = "your-ssid-password-here"`

Once your credentials are entered, click **Save** above the editor to save your changes to **settings.toml**.

![circuitpython_internet_test___settings_toml_editSettingsDotToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/920/medium640/circuitpython_internet_test___settings_toml_editSettingsDotToml.jpg?1724083365)

Once everything is saved to the&nbsp;board, **Restart** the Serial Console to see the data printed out!

![Output from wifi test showing the device IP, mac address, and time it took to get a ping response from google.com](https://cdn-learn.adafruit.com/assets/assets/000/136/980/medium800/adafruit_products_wifi_test_output.png?1747758628 )

## How the CircuitPython WiFi Example Works

In the basic WiFi test, the board connects to your SSID by importing your SSID and SSID password from the **settings.toml**** &nbsp;**file.

```python
wifi.radio.connect(os.getenv('CIRCUITPY_WIFI_SSID'), os.getenv('CIRCUITPY_WIFI_PASSWORD'))
```

Then, your MAC address and IP address are printed to the REPL.

```python
#  prints MAC address to REPL
print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])

#  prints IP address to REPL
print("My IP address is", wifi.radio.ipv4_address)
```

Finally, google.com is pinged. The amount of time it takes to ping is printed to the REPL and the code stops running.

```python
#  pings Google
ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000))
```

By successfully running this WiFi test code, you can confirm that your board is connecting to WiFi with CircuitPython successfully and you can move on to more advanced projects.

# Adafruit Sparkle Motion Stick

## Adafruit IO

Adafruit IO gives you the option to disconnect your microcontroller from your computer and run it off of USB power or a battery, and still be able to see the data. It also allows you to send data to your microcontroller, such as NeoPixel colors. This example shows how to both send data to and receive data from Adafruit IO. It pulls from a "random" number generator and sends the "random" number _to_ Adafruit IO, while simultaneously listening for NeoPixel color data _from_ Adafruit IO.

## NeoPixel Location
![Sparkle Motion Stick illustration with the builtin NeoPixel near the IR receiver and button highlighted.](https://cdn-learn.adafruit.com/assets/assets/000/136/981/medium800/adafruit_products_neopixel_highlight.png?1747758748 )

## Adafruit IO Feeds and Dashboard

The first thing you'll need to do, is head over to [Adafruit IO](https://io.adafruit.com/) and make sure your account is set up.

Then, you need to [create two feeds](https://learn.adafruit.com/adafruit-io-basics-feeds/creating-a-feed) called **neopixel** and **random**. These are case sensitive!

Next, you'll [create a dashboard](https://learn.adafruit.com/adafruit-io-basics-dashboards/creating-a-dashboard) for the NeoPixel Color Picker. You can name the dashboard whatever you like.

Once the dashboard is created, you'll want to [add a color picker block](https://learn.adafruit.com/adafruit-io-basics-dashboards/adding-blocks). The color picker block is highlighted by a red arrow in the image below.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/400/medium800/adafruit_io_send_and_recieve_data_AIO_choose_color_picker_block.png?1646162219)

Once you choose the color picker block, you'll need to connect a feed to it. Check the box next to **neopixel**.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/402/medium800/adafruit_io_send_and_recieve_data_AIO_connect_a_feed_to_color_picker.png?1646162290)

Finally, a Block Settings page will come up. You can add an optional block title here. Then you press **Create Block**.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/403/medium800/adafruit_io_send_and_recieve_data_AIO_color_picker_block_settings.png?1646162334)

The dashboard should look something like the following.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/404/medium800/adafruit_io_send_and_recieve_data_AIO_Dashboard_color_picker.png?1646162566)

Now that things are set up on the Adafruit IO end, you can continue on to the code on your microcontroller!

## Adafruit IO settings.toml

This example requires you to provide your Wi-Fi credentials, and your Adafruit IO username and key. To do this, you'll want to create a **settings.toml** file on your **CIRCUITPY** drive.

To obtain your Adafruit IO key, follow [the initial steps on this page](https://learn.adafruit.com/adafruit-io-home-security/adafruit-io-setup).

Your **settings.toml** file should be structured in a certain way, and contain all the necessary information. Follow these instructions to [create your settings.toml file](https://learn.adafruit.com/pico-w-wifi-with-circuitpython/create-your-settings-toml-file).

## Adafruit IO Example Code

To run this example, you need to first install the NeoPixel, Adafruit IO, and Adafruit MiniMQTT libraries into the **lib** folder on your board. Then you need to update **code.py** with the example script.

In the example below, click the&nbsp; **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file. You'll see a **code.py** file and **/lib** folder.

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

## Update the **/lib** Folder
In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Folders**.

![adafruit_io_send_and_recieve_data_uploadFolders.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/923/medium640/adafruit_io_send_and_recieve_data_uploadFolders.jpg?1724097455)

Navigate to the project bundle that you downloaded and select the **/lib folder**.

![adafruit_io_send_and_recieve_data_ioLib.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/924/medium640/adafruit_io_send_and_recieve_data_ioLib.jpg?1724097754)

You'll be asked if you want to upload the **/lib** folder from the&nbsp;Project Bundle. Click **Upload**.

![adafruit_io_send_and_recieve_data_ioUpload.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/925/medium640/adafruit_io_send_and_recieve_data_ioUpload.jpg?1724097803)

After the upload finishes, you can open the **lib** folder to view the library files required for the Adafruit IO example.

![adafruit_io_send_and_recieve_data_ioLibs.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/926/medium640/adafruit_io_send_and_recieve_data_ioLibs.jpg?1724097856)

## Update **code.py**
In the editor window in your browser, click the **Open** button to view the file dialog. Then, click the **Upload** button and select **Upload Files**.

![adafruit_io_send_and_recieve_data_upload.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/927/medium640/adafruit_io_send_and_recieve_data_upload.jpg?1724097889)

Navigate to the project bundle that you downloaded and select the **code.py** file.

![adafruit_io_send_and_recieve_data_code_dot_py.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/928/medium640/adafruit_io_send_and_recieve_data_code_dot_py.jpg?1724097913)

You'll be asked if you want to overwrite the previous **code.py** with the new **code.py** file from the Project Bundle. Click **OK**.

![adafruit_io_send_and_recieve_data_overwrite.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/929/medium640/adafruit_io_send_and_recieve_data_overwrite.jpg?1724097932)

## Update Your **settings.toml** File

Remember to add your **settings.toml** file as described earlier in this page. You'll need to include your `ADAFRUIT_AIO_USERNAME`, `ADAFRUIT_AIO_KEY`, `CIRCUITPY_WIFI_SSID` and `CIRCUITPY_WIFI_PASSWORD` in the file.

You can edit the file manually in the USB code editor by clicking **Open** , selecting **settings.toml** and clicking **Open** at the bottom of the dialog box.

![adafruit_io_send_and_recieve_data_openSettingsDotToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/930/medium640/adafruit_io_send_and_recieve_data_openSettingsDotToml.jpg?1724098044)

With **settings.toml** open in the editor, you can add your WiFi and Adafruit IO credentials:

`CIRCUITPY_WIFI_SSID = "your-ssid-here"`  
`CIRCUITPY_WIFI_PASSWORD = "your-ssid-password-here"`  
`ADAFRUIT_AIO_USERNAME = "your-aio-username-here"`  
`ADAFRUIT_AIO_KEY = "your-aio-key-here"`

Once your credentials are entered, click **Save** above the editor to save your changes to **settings.toml**.

![adafruit_io_send_and_recieve_data_ioSettingsToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/931/medium640/adafruit_io_send_and_recieve_data_ioSettingsToml.jpg?1724098221)

Once everything is saved to the&nbsp;board, **Restart** the Serial Console to run the new **code.py**. You'll see the connection info and current readings printed out in the console.

![Output from Adafruit IO example showing random numbers being sent to AIO, and colors being recieved from AIO.](https://cdn-learn.adafruit.com/assets/assets/000/136/982/medium800/adafruit_products_aio_color_rndnum_output.png?1747759207 )

## NeoPixel Color Change

To change the color of the NeoPixel, go to the NeoPixel Adafruit IO dashboard you created at the beginning, and click on the colored circle in the ColorPicker block. It will bring up the following.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/405/medium800/adafruit_io_send_and_recieve_data_AIO_color_picker_choose_color.png?1646162719)

You can move the dot in the box around, and the slider line across the gradient to choose the perfect color. Choose a new color and click **SAVE**.

The NeoPixel color will update, and you will see the new value printed to the serial console, as shown below.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/433/medium800/adafruit_io_send_and_recieve_data_AIO_template_serial_output_neopixel_color_change.png?1646242768)

## Code Walkthrough

This example contains three `try`/`except` blocks. These are included where the code is likely to fail due to WiFi or Adafruit IO connection failures. WiFi can be finicky, and without these code blocks, if the connection was lost, the code would crash. Instead, it is designed to reset the board and start the code over again to reestablish the connection, regardless of the cause. This ensures your code will continue running. The details of these blocks are explained below.

First you import all of the necessary modules and libraries.

```python
import time
import ssl
import os
from random import randint
import socketpool
import wifi
import board
import neopixel
import adafruit_minimqtt.adafruit_minimqtt as MQTT
from adafruit_io.adafruit_io import IO_MQTT
```

Info: Note that if a **settings.toml** file is not present on your **CIRCUITPY** drive, the code will fail to run, and you will receive an error in the serial console. Add a **settings.toml** file to your **CIRCUITPY** drive to resolve this error.

The WiFi attempts to connect, and prints the status to the serial console. If it connects successfully, the code continues onto the NeoPixel set up.

```python
try:
    print("Connecting to %s" % os.getenv("CIRCUITPY_WIFI_SSID"))
    wifi.radio.connect(os.getenv("CIRCUITPY_WIFI_SSID"), os.getenv("CIRCUITPY_WIFI_PASSWORD"))
    print("Connected to %s!" % os.getenv("CIRCUITPY_WIFI_SSID"))
```

If the WiFi connection is not successful, the error will be printed to the serial console, and the board will hard reset after 30 seconds.

```python
except Exception as e:  # pylint: disable=broad-except
    print("Failed to connect to WiFi. Error:", e, "\nBoard will hard reset in 30 seconds.")
    time.sleep(30)
    microcontroller.reset()
```

Once the WiFi successfully connects, the NeoPixel object is initiated.

```python
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3)
```

Following that are two callback methods. For more details, check out [this guide](https://learn.adafruit.com/mqtt-in-circuitpython/code-walkthrough#minimqtt-callback-methods-3034067-9). The `connected` method subscribes to the neopixel feed on Adafruit IO. The `message` callback checks for updates to the neopixel feed, and turns the pixel the color from the feed.

```python
def connected(client):
    print("Connected to Adafruit IO!  Listening for NeoPixel changes...")
    # Subscribe to Adafruit IO feed called "neopixel"
    client.subscribe("neopixel")


# pylint: disable=unused-argument
def message(client, feed_id, payload):
    print("Feed {0} received new value: {1}".format(feed_id, payload))
    if feed_id == "neopixel":
        pixel.fill(int(payload[1:], 16))
```

You create a socket pool, use that to initialise the new MQTT Client object, and use that to initialise the Adafruit IO MQTT "helper".

```python
pool = socketpool.SocketPool(wifi.radio)

mqtt_client = MQTT.MQTT(
    broker="io.adafruit.com",
    username=os.getenv("ADAFRUIT_AIO_USERNAME"),
    password=os.getenv("ADAFRUIT_AIO_KEY"),
    socket_pool=pool,
    ssl_context=ssl.create_default_context(),
)

io = IO_MQTT(mqtt_client)
```

You set up the callback methods mentioned above.

```python
io.on_connect = connected
io.on_message = message
```

Next, you attempt to connect the client to the MQTT broker. If connection is successful, the code continues on to the `timestamp`.

```python
try:
    io.connect()
```

If the MQTT broker connection is not successful, the error is printed to the serial console, and the board will hard reset after 30 seconds.

```python
except Exception as e:
    print("Failed to connect to Adafruit IO. Error:", e, "\nBoard will hard reset in 30 seconds.")
    time.sleep(30)
    microcontroller.reset()
```

Once the broker is connected, you set the `timestamp` to `0` immediately before the loop.

```python
timestamp = 0
```

Inside the loop, you attempt to do two things. You first explicitly poll the message loop. Check out [this guide](https://learn.adafruit.com/mqtt-in-circuitpython/advanced-minimqtt-usage#minimqtt-loop-3034264-1) for more details on that.

```python
while True:
    try:
        io.loop()
```

Second, you have a block of code that runs every 10 seconds. Inside, you obtain a "random" value between 0-255 inclusive, print it to the serial console, and publish it to an Adafruit IO feed. Finally, you reset timestamp so the block of code knows when another 10 seconds has passed, and runs again.

```python
[...]
        if (time.monotonic() - timestamp) &gt;= 10:
            random_number = "{}".format(randint(0, 255))
            print("Current 'random' number: {}".format(random_number))
            io.publish("random", random_number)
            timestamp = time.monotonic()
```

If at any time WiFi or Adafruit IO disconnects, the code will print the error to the serial console, and the board will hard reset after 30 seconds.

```python
[...]
    except Exception as e:
        print("Failed to get or send data, or connect. Error:", e,
              "\nBoard will hard reset in 30 seconds.")
        time.sleep(30)
        microcontroller.reset()
```

That's all there is to using CircuitPython and Adafruit IO to send data to Adafruit IO, and receive data from it!

# Adafruit Sparkle Motion Stick

## Arduino IDE Setup

We primarily recommend using the ESP32 chipsets with Arduino. Don't forget you will also need to install the SiLabs CP2104 Driver if you are using an ESP32 board with USB-to-Serial converter! (There's no harm in doing it, so we recommend even if you aren't.)

### Install Arduino IDE

The first thing you will need to do is to download the latest release of the Arduino IDE. You will need to&nbsp;be using&nbsp; **version 1.8** &nbsp;or higher for this guide.

[Arduino IDE Download](http://www.arduino.cc/en/Main/Software)
### Install CP2104 / CP2102N USB Driver

Many ESP32 boards have a USB-to-Serial converter that talks to the chip itself, and will need a driver on your computer's operating system. The driver is available for Mac and Windows. It is already built into Linux.

[Click here to download the CP2104 USB Driver](http://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers)
### Install CH9102 / CH34X USB Driver

Newer ESP32 boards have a different USB-to-serial converter that talks to the chip itself, and will need a driver on your computer's operating system. The driver is available for Mac and Windows. It is already built into Linux.

If you would like more detail, check out [the guide on installing these drivers](https://learn.adafruit.com/how-to-install-drivers-for-wch-usb-to-serial-chips).

[Click here to download the Windows driver](http://www.wch-ic.com/downloads/CH343SER_ZIP.html)
[Click here to download the Mac driver](http://www.wch-ic.com/downloads/CH34XSER_MAC_ZIP.html)
### Install ESP32 Board Support Package from GitHub

For this board, we recommend you _don't_ use 'release' version of Espressif's board support package because the current release doesn't include board support.

Instead we will install the "very latest" [by following these instructions](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#windows-manual-installation) (scroll down for mac and Linux as well

Basically, install by **git clone** ing the Espressif ESP32 board support to get the very latest version of the code.

In the **Tools → Board** submenu you should see **ESP32 Arduino (in sketchbook)** and in that dropdown it should contain the ESP32 boards along with all the latest ESP32 boards.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/605/medium800/esp32_arduino_ide_setup_image.png?1646944312)

Look for the board called **Adafruit Sparkle Motion Stick (ESP32)**.

![sparkle motion stick in board selection menu](https://cdn-learn.adafruit.com/assets/assets/000/137/014/medium800/adafruit_products_Screenshot_2025-05-21_113904.png?1747841971 )

The upload speed can be changed: faster speed makes uploads take less time but sometimes can cause upload issues. **921600** should work fine, but if you're having issues, you can drop down lower.

# Adafruit Sparkle Motion Stick

## Blink

The first and most basic program you can upload to your Arduino is the classic Blink sketch. This takes something on the board and makes it, well, blink! On and off. It's a great way to make sure everything is working and you're uploading your sketch to the right board and right configuration.

When all else fails, you can always come back to Blink!

![Sparkle Motion Stick running the Blink Arduino example sketch. It's builtin LED is blinking on and off.](https://cdn-learn.adafruit.com/assets/assets/000/136/998/medium800thumb/adafruit_products_blink.jpg?1747771494 )

# Pre-Flight Check: Get Arduino IDE & Hardware Set Up

This lesson assumes you have Arduino IDE set up. This is a generalized checklist, some elements may not apply to your hardware. If you haven't yet, check the previous steps in the guide to make sure you:

- **Install the very latest Arduino IDE for Desktop** (not all boards are supported by the Web IDE so we don't recommend it)
- **Install any board support packages (BSP) required for your hardware.** Some boards are built in defaults on the IDE, but lots are not! You may need to install plug-in support which is called the BSP.
- **Get a Data/Sync USB cable for connecting your hardware.** A _significant_ amount of problems folks have stem from not having a USB cable with data pins. Yes, these cursed cables roam the land, making your life hard. If you find a USB cable that doesn't work for data/sync, _throw it away immediately_! There is no need to keep it around, cables are very inexpensive these days.
- **Install any drivers required** - If you have a board with a FTDI or CP210x chip, you may need to get separate drivers. If your board has native USB, it probably doesn't need anything. After installing, reboot to make sure the driver sinks in.
- **Connect the board to your computer.** If your board has a power LED, make sure it's lit. Is there a power switch? Make sure its turned On!

# Start up Arduino IDE and Select Board/Port

OK now you are prepared! Open the Arduino IDE on your computer. Now you have to tell the IDE what board you are using, and how you want to connect to it.

In the IDE find the **Tools** menu. You will use this to select the board. If you switch boards, you _must switch the selection!_ So always double-check before you upload code in a new session.

![Arduino IDE tools menu with Tools, Board, ESP32 Arduino (in Sketchbook), and Adafruit Aprkle Motion Stick (ESP32) items highlighted in their respective menus)](https://cdn-learn.adafruit.com/assets/assets/000/136/987/medium800/adafruit_products_board_select_highlights.png?1747766053 )

# New Blink Sketch

OK lets make a new blink sketch! From the **File** menu, select **New**

![](https://cdn-learn.adafruit.com/assets/assets/000/107/498/medium800/blink__image.png?1640454932)

Then in the new window, copy and paste this text:

```auto
int led = LED_BUILTIN;

void setup() {
  // Some boards work best if we also make a serial connection
  Serial.begin(115200);

  // set LED to be an output pin
  pinMode(led, OUTPUT);
}

void loop() {
  // Say hi!
  Serial.println("Hello!");
  
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                // wait for a half second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                // wait for a half second
}
```

Info: 

One note you'll see is that we reference the LED with the constant `LED_BUILTIN` rather than a number. That's because, historically, the built in LED was on pin 13 for Arduinos. But in the decades since, boards don't always have a pin 13, or maybe it could not be used for an LED. So the LED could have moved to another pin. It's best to use `LED_BUILTIN` so you don't get the pin number confused!

# Verify (Compile) Sketch

OK now you can click the Verify button to convert the sketch into binary data to be uploaded to the board.

Note that Verifying a sketch is the same as Compiling a sketch - so we will use the words interchangeably

![](https://cdn-learn.adafruit.com/assets/assets/000/107/503/medium800/blink__image.png?1640455847)

During verification/compilation, the computer will do a bunch of work to collect all the libraries and code and the results will appear in the bottom window of the IDE

![](https://cdn-learn.adafruit.com/assets/assets/000/107/500/medium800/blink__image.png?1640455335)

If something went wrong with compilation, you will get red warning/error text in the bottom window letting you know what the error was. It will also highlight the line with an error

For example, here I had the wrong board selected - and the selected board does not have a built in LED!

![](https://cdn-learn.adafruit.com/assets/assets/000/107/501/medium800/blink__image.png?1640455513)

Here's another common error, in my haste I forgot to add a `;` at the end of a line. The compiler warns me that it's looking for one - note that the error is actually a few lines up!

![](https://cdn-learn.adafruit.com/assets/assets/000/107/502/medium800/blink__image.png?1640455650)

Info: Turning on detailed compilation warnings and output can be very helpful sometimes - It's in Preferences under "Show Verbose Output During:" and check the Compilation button. If you ever need to get help from others, be sure to do this and then provide all the text that is output. It can assist in determining what happened!

On success you will see something like this white text output and the message **Done compiling.** in the message area.

![](https://cdn-learn.adafruit.com/assets/assets/000/107/504/medium800/blink__image.png?1640455995)

# Upload Sketch

Once the code is verified/compiling cleanly you can upload it to your board. Click the **Upload** button

![](https://cdn-learn.adafruit.com/assets/assets/000/107/499/medium800/blink__image.png?1640455265)

The IDE will try to compile the sketch again for good measure, then it will try to connect to the board and upload a the file.

**This is actually one of the hardest parts for beginners because it's where a lot of things can go wrong.**

However, lets start with what it looks like on success! Here's what your board upload process looks like when it goes right:

![Arduino IDE output pane showing the messages that are output when uploading the blink example to the device.](https://cdn-learn.adafruit.com/assets/assets/000/136/988/medium800/adafruit_products_blink_upload_output.png?1747766194 )

Often times you will get a warning like this, which is kind of vague:

`No device found on COM66` (or whatever port is selected)  
`An error occurred while uploading the sketch`

![](https://cdn-learn.adafruit.com/assets/assets/000/107/505/medium800/blink__image.png?1640456582)

This could be a few things.

First up, **check again that you have the correct board selected!** Many electronics boards have very similar names or look, and often times folks grab a board different from what they thought.

Second, **make sure you selected the right port!** If you have the wrong port or no port selected, Arduino doesn't know where to look for your board.

If both of those are correct, the next step is to enable verbose upload messages.

Before continuing we _really really_ suggest turning on **Verbose Upload** messages, it will help in this process because you will be able to see what the IDE is trying to do. It's a checkbox in the **Preferences** menu.

![](https://cdn-learn.adafruit.com/assets/assets/000/107/507/medium800/blink__image.png?1640457254)

Now you can try uploading again!

![](https://cdn-learn.adafruit.com/assets/assets/000/107/506/medium800/blink__image.png?1640457185)

This time, you should have success!

After uploading this way, be sure to **click the reset button** - it sort of makes sure that the board got a good reset and will come back to life nicely.

# Finally, a Blink!

OK it was a journey but now we're here and you can enjoy your blinking LED. Next up, try to change the delay between blinks and re-upload. It's a good way to make sure your upload process is smooth and practiced.

![Sparkle Motion Stick running the Blink Arduino example sketch. It's builtin LED is blinking on and off.](https://cdn-learn.adafruit.com/assets/assets/000/137/000/medium800thumb/adafruit_products_blink.jpg?1747772808 )

# Adafruit Sparkle Motion Stick

## Built-In NeoPixel

Your board has a built-in RGB NeoPixel status LED. You can use Arduino code to control the color and brightness of this LED. It is also used to indicate the bootloader status.

A NeoPixel is what Adafruit calls the WS281x family of addressable RGB LEDs. It contains three LEDs - a red one, a green one and a blue one - along side a driver chip in a tiny package controlled by a single pin. They can be used individually (as in the built-in LED on your board), or chained together in strips or other creative form factors. NeoPixels do not light up on their own; they require a microcontroller. So, it's super convenient that the NeoPixel is built in to your microcontroller board!

This page will cover using Arduino to control the status RGB NeoPixel built into your microcontroller. Time to get started!

## NeoPixel Location
![Sparkle Motion Stick illustration with the builtin NeoPixel near the IR receiver and button highlighted.](https://cdn-learn.adafruit.com/assets/assets/000/136/984/medium800/adafruit_products_neopixel_highlight.png?1747763524 )

## Arduino Library Installation

You can install the necessary libraries from the Library Manager. To open, click **Sketch \> Include Library \> Manage Libraries...**

![](https://cdn-learn.adafruit.com/assets/assets/000/132/296/medium800/arduino_rainbow_neopixel_example_Arduino_Open_Library_Manager.png?1726175295)

Search for **NeoPixel** , and install the **Adafruit**  **NeoPixel** library.

![](https://cdn-learn.adafruit.com/assets/assets/000/132/297/medium800/arduino_rainbow_neopixel_example_Screenshot_2024-09-09_095020.png?1726175334)

Info: There are no additional library dependencies for the Adafruit NeoPixel library.

## Rainbow Swirl Demo
```cpp
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include &lt;Adafruit_NeoPixel.h&gt;

#define NUMPIXELS 1
Adafruit_NeoPixel pixel(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(115200);

  pixel.begin();
  pixel.setBrightness(25);
  pixel.show();

}

uint16_t firstPixelHue = 0;

void loop() {  
  firstPixelHue += 256;
  for(int i=0; i&lt;pixel.numPixels(); i++) {
      int pixelHue = firstPixelHue + (i * 65536L / pixel.numPixels());
      pixel.setPixelColor(i, pixel.gamma32(pixel.ColorHSV(pixelHue)));
    }
  pixel.show();
  
  delay(10);

}
```

Upload the sketch to your board. You'll see the onboard NeoPixel run through a looping rainbow animation.

# Adafruit Sparkle Motion Stick

## Arduino Sparkle Motion Demo

![Sparkle Motion Stick running multi strip NeoPixel animation example. Two connected NeoPixel strips are cycling through rainbow colors.](https://cdn-learn.adafruit.com/assets/assets/000/137/003/medium800thumb/adafruit_products_multistrip_animation.jpg?1747775696 )

The main use of the Sparkle Motion Stick is lighting up RGB LEDs to dazzle and delight. Using the Sparkle Motion with Arduino involves installing the [Adafruit\_NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) library and running the provided example code. In the example below, you'll attach two NeoPixel strips to the Sparkle Motion Stick and see how you can write code to run two different LED animations on two strips of NeoPixels at the same time.

## Wiring
NeoPixels

- **terminal block -** to **GND** on one NeoPixel strip. (black wire)
- **terminal block +** to **5V** on one NeoPixel strip. (red wire)
- **GND** on one NeoPixel strip to **GND** on the other NeoPixel strip (black wire)
- **5V** on one NeoPixel strip to **5V** on the other NeoPixel strip (red wire)
- **terminal block 21** to **DIN** on the first NeoPixel strip. (orange wire)
- **terminal block 22** to **DIN** on the second NeoPixel strip. (yellow wire)
- &nbsp;

![Sparkle Motion Stick Illustration with wiring diagram depicting the connections for the NeoPixel animation example](https://cdn-learn.adafruit.com/assets/assets/000/137/002/medium640/adafruit_products_led_animation_multistrip.png?1747773424)

## Library Installation
You can install the&nbsp; **Adafruit NeoPixel** library for Arduino using the Library Manager in the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/134/812/medium800/adafruit_products_Arduino_Open_Library_Manager.png?1737994664)

Click the&nbsp; **Manage Libraries ...** &nbsp;menu item, search for&nbsp; **Adafruit NeoPixel** &nbsp;and select the&nbsp; **Adafruit NeoPixel** &nbsp;library:

![](https://cdn-learn.adafruit.com/assets/assets/000/134/813/medium800/adafruit_products_neoPixelLibrary.png?1737994705)

Info: No additional dependencies are required for the NeoPixel library.

## Example Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Sparkle_Motion_Examples/Arduino_Sparkle_Motion_Multi_NeoPixels/Arduino_Sparkle_Motion_Multi_NeoPixels.ino

Upload the example code to the Sparkle Motion Stick. You'll see both strips cycle through the rainbow swirl, but in a different order on each strip.

![Sparkle Motion Stick running multi strip NeoPixel animation example. Two connected NeoPixel strips are cycling through rainbow colors.](https://cdn-learn.adafruit.com/assets/assets/000/137/004/medium800thumb/adafruit_products_multistrip_animation.jpg?1747775755 )

# Adafruit Sparkle Motion Stick

## Arduino IR Remote

The Adafruit Sparkle Motion Stick has an IR receiver built-in for all of your remote controlling needs. The [IRremote](https://docs.arduino.cc/libraries/irremote/) library makes it easy to decode the signals sent to the receiver. This example will get you started by demonstrating how to use one of our [mini remote controls](https://www.adafruit.com/product/389) to change the color and brightness of a connected strip of NeoPixels.

## IR Receiver & NeoPixel Output Location
![ir and neopixel terminal block outlined in red](https://cdn-learn.adafruit.com/assets/assets/000/137/010/medium800/adafruit_products_ir_red.jpg?1747839556 )

The IR Receiver is connected to pin `10`. This example assumes the NeoPixel strip will be plugged in to the terminal blocks for pin&nbsp;`21`.

## Necessary Hardware

You'll need an IR remote that uses one of the protocols supported by the [IRremote](https://docs.arduino.cc/libraries/irremote/) library, and any strip of NeoPixels. The following items are the ones depicted on this page.

### NeoPixel Stick - 8 x 5050 RGB LED with Integrated Drivers

[NeoPixel Stick - 8 x 5050 RGB LED with Integrated Drivers](https://www.adafruit.com/product/1426)
Make your own little LED strip arrangement with this stick of NeoPixel LEDs. We crammed 8 of the tiny 5050 (5mm x 5mm) smart RGB LEDs onto a PCB with mounting holes and a chainable design. Use only one microcontroller pin to control as many as you can chain together! Each LED is addressable as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1426)
[Related Guides to the Product](https://learn.adafruit.com/products/1426/guides)
![NeoPixel Stick with 8 x 5050 RGB LED ](https://cdn-shop.adafruit.com/640x480/1426-05.jpg)

### Mini Remote Control

[Mini Remote Control](https://www.adafruit.com/product/389)
This little remote control would be handy for controlling a robot or other project from across the room. It has 21 buttons and a layout we thought was handy: directional buttons and number entry buttons. The remote uses the NEC encoding type and sends data codes 0 thru 26 (it skips #3, #7,...

In Stock
[Buy Now](https://www.adafruit.com/product/389)
[Related Guides to the Product](https://learn.adafruit.com/products/389/guides)
![Mini Remote Control with 21 buttons](https://cdn-shop.adafruit.com/640x480/389-03.jpg)

## Wiring
NeoPixels

- **Terminal block GND** &nbsp;to **GND** on the NeoPixel strip. (black wire)
- **Terminal block 5V** &nbsp;to **5V** on the NeoPixel strip. (red wire)
- **Terminal block 21** to **DIN** on the NeoPixel strip. (blue wire)

![fritzing diagram with sparkle motion stick and neopixels](https://cdn-learn.adafruit.com/assets/assets/000/137/012/medium640/adafruit_products_stickNeo.jpg?1747839773)

## Library Installation

You can install the&nbsp; **Adafruit NeoPixel** , and&nbsp; **IRremote** libraries for Arduino using the Library Manager in the Arduino IDE.

![library menu](https://cdn-learn.adafruit.com/assets/assets/000/137/007/medium800/adafruit_products_Arduino_Open_Library_Manager.png?1747837213 )

Click the&nbsp; **Manage Libraries ...** &nbsp;menu item, search for&nbsp; **Adafruit NeoPixel** &nbsp;and click the Install button on the **Adafruit NeoPixel** result:

![neopixel library install](https://cdn-learn.adafruit.com/assets/assets/000/137/008/medium800/adafruit_products_Screenshot_2025-05-21_103508.png?1747838919 )

Next, search for **IRremote** and click the install button on the&nbsp; **IRremote** result:

![ir remote library install](https://cdn-learn.adafruit.com/assets/assets/000/137/009/medium800/adafruit_products_Screenshot_2025-05-21_103601.png?1747838933 )

Info: No additional dependencies are required for the NeoPixel or IRremote libraries.

## Example Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Sparkle_Motion_Stick_Examples/Arduino_Sparkle_Motion_Stick_IR_Remote/Arduino_Sparkle_Motion_Stick_IR_Remote.ino

Once the code is running, press the up and down arrow keys on the remote to increase and decrease the brightness. Press the left and right arrow keys to cycle through the available colors forward or backward.

# Adafruit Sparkle Motion Stick

## I2S Mic

![Sparkle Motion Stick with the I2C mic hilighted](https://cdn-learn.adafruit.com/assets/assets/000/137/005/medium800/adafruit_products_sparkle_i2smic_highlights.png?1747776189 )

You can use the onboard I2S microphone with the I2S library built into the Espressif board support package. The I2S microphone is connected to the following pins on the Sparkle Motion Stick:

- BCLK: 14
- WS: 12
- DATA\_IN: 13

The example below will plot samples from the mic to the plotter inside the Arduino IDE.

Info: No additional libraries need to be installed for this example - the I2S library is included in the Espressif board support package.

## Example Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Sparkle_Motion_Stick_Examples/Arduino_I2S_SparkleMotionStick/Arduino_I2S_SparkleMotionStick.ino

Upload the sketch to your board and open up the Serial Plotter ( **Tools -\> Serial Plotter** ) at **500000 baud**. You'll see the raw samples and average samples from the I2S microphone plotted over time.

![Arduino IDE serial graph showing output from the I2S mic example graphed.](https://cdn-learn.adafruit.com/assets/assets/000/137/006/medium800thumb/adafruit_products_i2s_mic_output.jpg?1747776903 )

# Adafruit Sparkle Motion Stick

## WiFi Test

Thankfully if you have ESP32 sketches, they'll 'just work' with variations of ESP32. You can find a wide range of examples in the **File-\>Examples-\>Examples for Adafruit Metro ESP32-S2** subheading (the name of the board may vary so it could be **"Examples for Adafruit Feather ESP32 V2"** etc)

![](https://cdn-learn.adafruit.com/assets/assets/000/097/028/medium800/adafruit_products_image.png?1605222761)

Let's start by scanning the local networks.

**Load up the WiFiScan example** under **Examples-\>Examples for YOUR BOARDNAME-\>WiFi-\>WiFiScan**

![](https://cdn-learn.adafruit.com/assets/assets/000/096/993/medium800/adafruit_products_Screen_Shot_2020-11-11_at_12.28.51_PM.png?1605115789)

And **upload this example to your board**. The ESP32 should scan and find WiFi networks around you.

For ESP32, open the serial monitor, to see the scan begin.

For ESP32-S2, -S3 and -C3, don't forget you have to click Reset after uploading through the ROM bootloader. Then select the new USB Serial port created by the ESP32. It will take a few seconds for the board to complete the scan.

![](https://cdn-learn.adafruit.com/assets/assets/000/097/029/medium800/adafruit_products_image.png?1605223012)

If you can not scan any networks, check your power supply. You need a solid power supply in order for the ESP32 to not brown out. A skinny USB cable or drained battery can cause issues.

## WiFi Connection Test

Now that you can scan networks around you, its time to connect to the Internet!

Copy the example below and paste it into the Arduino IDE:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/ESP32_S2_WiFi_Tests/WiFiWebClient/WiFiWebClient.ino

 **NOTE:** You must **change the `SECRET_SSID` and `SECRET_PASS` in the example code to your WiFi SSID and password** before uploading this to your board.

![](https://cdn-learn.adafruit.com/assets/assets/000/097/030/medium800/adafruit_products_image.png?1605223125)

After you've set it correctly, upload and check the serial monitor. You should see the following. If not, go back, check wiring, power and your SSID/password

![](https://cdn-learn.adafruit.com/assets/assets/000/097/009/medium800/adafruit_products__dev_cu_usbmodem14101.png?1605127946)

Info: If you have issues establishing a connection, try power cycling the board by unplugging and replugging the USB cable.

# Adafruit Sparkle Motion Stick

## Factory Reset

Warning: The Sparkle Motion Stick does not have a reset button, so to reset the board you will need to unplug it from USB, wait a few seconds and then and plug it back in.

Your microcontroller ships running a factory demo. It's lovely, but you probably had other plans for the board. As you start working with your board, you may want to return to the original code to begin again, or you may find your board gets into a bad state. Either way, this page has you covered.

## Factory Reset Example Code
If you're still able to load Arduino sketches, you can load the following sketch onto your board to return it to its original state.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Factory_Tests/Adafruit_Sparkle_Motion_Stick_FactoryTest/Adafruit_Sparkle_Motion_Stick_FactoryTest.ino

Your board is now back to its factory-shipped state! You can now begin again with your plans for your board.

## Factory Reset .bin
If your board is in a state where Arduino isn't working, you may need to use these tools to flash a .bin file directly onto your board.

There are two ways to do a factory reset. The first is using WebSerial through a Chromium-based browser, and the second is using `esptool` via command line. **We highly recommend using WebSerial through Chrome/Chromium.**

First you'll need to download the factory-reset.bin file. Save the following file wherever is convenient for you. You'll need access to it for both tools.

[Click to download the Adafruit Sparkle Motion Stick Factory Reset .BIN File](https://github.com/adafruit/Adafruit-Sparkle-Motion-Stick-PCB/raw/main/factory-reset/Adafruit_Sparkle_Motion_Stick_Factory_Reset.bin)
Now that you've downloaded the .bin file, you're ready to continue with the factory reset process. The next two sections walk you through using WebSerial and `esptool`.

## The WebSerial ESPTool Method
Primary: 

This method uses the WebSerial ESPTool through Chrome or a Chromium-based browser. The WebSerial ESPTool was designed to be a web-capable option for programming ESP32 boards. It allows you to erase the contents of the microcontroller and program up to four files at different offsets.

You will have to use a Chromium browser (like Chrome, Opera, Edge...) for this to work, Safari and Firefox, etc. are _not_ supported because we need Web Serial and only Chromium is supporting it to the level needed.

Follow the steps to complete the factory reset.

Warning: 

### Connect

You should have plugged in **only the ESP32 that you intend to flash**. That way there's no confusion in picking the proper port when it's time!

In the **Chrome browser** visit [https://adafruit.github.io/Adafruit\_WebSerial\_ESPTool/](https://adafruit.github.io/Adafruit_WebSerial_ESPTool/). You should see something like the image shown.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.07.03_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/492/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.07.03_PM.png?1649110083)

Press the&nbsp; **Connect** &nbsp;button in the top right of the web browser. You will get a pop up asking you to select the COM or Serial port.

**Remember, you should remove all other USB devices so**  **_only_ the ESP32 board is attached, that way there's no confusion over multiple ports!**

On some systems, such as MacOS, there may be additional system ports that appear in the list.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.12.49_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/493/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.12.49_PM.png?1649110453)

The Javascript code will now try to connect to the ROM bootloader. It may timeout for a bit until it succeeds. On success, you will see that it is&nbsp; **Connected** &nbsp;and will print out a unique&nbsp; **MAC address** identifying the board along with other information that was detected.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.16.00_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/494/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.16.00_PM.png?1649110590)

&nbsp;

&nbsp;

Once you have successfully connected, the command toolbar will appear.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.18.26_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/496/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.18.26_PM.png?1649110775)

### Erase the Contents
To erase the contents, click the Erase button. You will be prompted whether you want to continue. Click OK to continue or if you changed your mind, just click cancel.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.19.58_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/497/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.19.58_PM.png?1649110871)

&nbsp;

You'll see "Erasing flash memory. Please wait..." This will eventually be followed by "Finished." and the amount of time it took to erase.

**Do not disconnect!** Immediately continue on to programming the ESP32.

![factory_reset___esp32_s2_WebSerial_ESPTool_erase_board_text.png](https://cdn-learn.adafruit.com/assets/assets/000/106/947/medium640/factory_reset___esp32_s2_WebSerial_ESPTool_erase_board_text.png?1638491869)

Danger: 

### Program the ESP32
Programming the microcontroller can be done with up to four files at different locations, but with the board-specific **factory-reset.bin** file, which you should have downloaded earlier, you only need to use one file.

Click on the first **Choose a file...**. (The tool will only attempt to program buttons with a file and a unique location.) Then, select the \*- **factory-reset.bin** file you downloaded in Step 1 that matches your board.

Verify that the&nbsp; **Offset** &nbsp;box next to the file location you used is (0x) **0**.

![install_uf2_bootloader_adafruit_products_image_(3).png](https://cdn-learn.adafruit.com/assets/assets/000/101/574/medium640/install_uf2_bootloader_adafruit_products_image_%283%29.png?1618608677)

Once you choose a file, the button text will change to match your filename. You can then select the **Program** button to begin flashing.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.22.13_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/500/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.22.13_PM.png?1649111131)

A progress bar will appear and after a minute or two, you will have written the firmware.

![esp32_factory_reset_Screen_Shot_2022-04-04_at_3.23.42_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/110/499/medium640/esp32_factory_reset_Screen_Shot_2022-04-04_at_3.23.42_PM.png?1649111082)

Once completed, you can skip down to the section titled Reset the Board.

## The `esptool` Method (for advanced users)
Danger: 

Alternatively, you can [use Espressif's esptool program](https://github.com/espressif/esptool)&nbsp;to communicate with the chip!&nbsp;`esptool`&nbsp;is the 'official' programming tool and is the most common/complete way to program an ESP chip.

### Install ESPTool.py

You will need to use the command line / Terminal to install and run&nbsp;`esptool`.

You will also need to have pip and Python installed (any version!).

Install the latest version using pip (you may be able to run&nbsp;`pip`&nbsp;without the&nbsp;`3`&nbsp;depending on your setup):

`pip3 install --upgrade esptool`

Then, you can run:

`esptool.py`

### Test the Installation

Run&nbsp;`esptool.py`&nbsp;in a new terminal/command line and verify you get something like the below:

![](https://cdn-learn.adafruit.com/assets/assets/000/109/599/medium800/esp32_factory_reset_ESP_factory_reset_esptool_verify.png?1646862954)

### Connect

Run the following command, replacing the `COM88` identifier after&nbsp;`--port`&nbsp;with the&nbsp;`COMxx`,&nbsp;`/dev/cu.usbmodemxx`&nbsp;or&nbsp;`/dev/ttySxx`&nbsp;you found above.

`esptool.py --port COM88 chip_id`

You should get a notice that it connected over that port and found an ESP32.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/600/medium800/esp32_factory_reset_ESP_factory_reset_esptool_connect.png?1646862962)

### Installing the Factory Test file

Run this command and replace the serial port name, `COM88`, with your matching port and `*-factory-reset.bin` with file you just downloaded

`esptool.py --port COM88 write_flash 0x0 *-factory-reset.bin`

Don't forget to change the `--port` name to match.

There might be a bit of a 'wait' when programming, where it doesn't seem like it's working. Give it a minute, it has to erase the old flash code which can cause it to seem like it's not running.

You'll finally get an output like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/109/601/medium800/esp32_factory_reset_ESP_factory_reset_esptool_install.png?1646862974)

Once completed, you can continue to the next section.

## Reset the board
Now that you've reprogrammed the board, you need to reset it to continue. Click the reset button to launch the new firmware.

Info: 

Warning: The Sparkle Motion Stick does not have a reset button so you will need to unplug the board from USB to reset it!

The NeoPixel LED on the Sparkle Motion Stick will display a rainbow swirl. If you open the Serial Monitor, you'll see a WiFi scan and amplitude readings from the I2S microphone.

![serial monitor output from the factory reset](https://cdn-learn.adafruit.com/assets/assets/000/137/001/medium800/adafruit_products_Screenshot_2025-05-20_162734.png?1747773031 )

You've successfully returned your board to a factory reset state!

## Older Versions of Chrome
Primary: 

We suggest updating to Chrome 89 or newer, as Web Serial is enabled by default.

If you must continue using an older version of Chrome, follow these steps to enable Web Serial.

If you receive an error like the one shown when you visit the WebSerial ESPTool site, you're likely running an older version of Chrome.

**You must be using Chrome 78 or later to use Web Serial.**

![factory_reset___esp32_s2_WebSerial_ESPTool_Not_Supported_Error.png](https://cdn-learn.adafruit.com/assets/assets/000/106/929/medium640/factory_reset___esp32_s2_WebSerial_ESPTool_Not_Supported_Error.png?1638484333)

To enable Web Serial in Chrome versions 78 through 88:

- Visit **chrome://flags** &nbsp;from within Chrome.
- Find and enable the&nbsp; **Experimental Web Platform features**
- **Restart Chrome**

![install_uf2_bootloader_adafruit_products_Enable_Features.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/562/medium640/install_uf2_bootloader_adafruit_products_Enable_Features.jpg?1618608210)

# Adafruit Sparkle Motion Stick

## Downloads

## Files

- [ESP32 datasheet](https://cdn-learn.adafruit.com/assets/assets/000/109/588/original/esp32-pico-mini-02_datasheet_en.pdf?1646852017)
- [CH343DS1 datasheet](https://cdn-learn.adafruit.com/assets/assets/000/134/549/original/CH343DS1.PDF?1737477957)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-Sparkle-Motion-Stick-PCB)
- [3D models on GitHub](https://github.com/adafruit/Adafruit_CAD_Parts/tree/main/6332%20Sparkle%20Motion%20Stick)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20Sparkle%20Motion%20Stick.fzpz)
- [PrettyPins pinout PDF](https://github.com/adafruit/Adafruit-Sparkle-Motion-Stick-PCB/blob/main/Adafruit_Sparkle_Motion_Stick_PrettyPins.pdf)
- [PrettyPins pinout SVG](https://github.com/adafruit/Adafruit-Sparkle-Motion-Stick-PCB/blob/main/Adafruit_Sparkle_Motion_Stick_PrettyPins.svg)

## Schematic and Fab Print
![schematic](https://cdn-learn.adafruit.com/assets/assets/000/136/846/medium800/adafruit_products_schem.png?1747252539 )

![fab print](https://cdn-learn.adafruit.com/assets/assets/000/136/847/medium800/adafruit_products_fab.png?1747252556 dimensions are in inches)

![](https://cdn-learn.adafruit.com/assets/assets/000/137/041/medium800/adafruit_products_6332_Sparkle_Motion_Stick.jpg?1747921339 )


## Primary Products

### Adafruit Sparkle Motion Stick - WLED-friendly USB Stick

[Adafruit Sparkle Motion Stick - WLED-friendly USB Stick](https://www.adafruit.com/product/6332)
The **Adafruit Sparkle Motion Stick** is part of our&nbsp;series of "Sparkle Motion" boards, which are our attempt to make the&nbsp;best small&nbsp;WLED-friendly smart LED driving board in the whole world. Our resident mermaid, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/6332)
[Related Guides to the Product](https://learn.adafruit.com/products/6332/guides)
### Adafruit Sparkle Motion Stick + Enclosure Kit

[Adafruit Sparkle Motion Stick + Enclosure Kit](https://www.adafruit.com/product/6333)
The **Adafruit Sparkle Motion Stick** is part of our&nbsp;series of "Sparkle Motion" boards, which are our attempt to make the&nbsp;best small&nbsp;WLED-friendly smart LED driving board in the whole world. Our resident mermaid, <a...></a...>

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

## Featured Products

### Snap-on Translucent USB Dongle Case - 48 x 22 x 12mm

[Snap-on Translucent USB Dongle Case - 48 x 22 x 12mm](https://www.adafruit.com/product/6176)
This simple **Snap-on USB Dongle Case** &nbsp;/ Enclosure is an inexpensive way to turn a bare PCB into a more durable project (as long as the PCB design shape is under you control). For much less than it would cost to get a custom 3D printed case, and way way less than injection...

In Stock
[Buy Now](https://www.adafruit.com/product/6176)
[Related Guides to the Product](https://learn.adafruit.com/products/6176/guides)
### Adafruit NeoPixel Digital RGB LED Strip - Black 30 LED 1m

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

Out of Stock
[Buy Now](https://www.adafruit.com/product/2552)
[Related Guides to the Product](https://learn.adafruit.com/products/2552/guides)
### Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix

[Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix](https://www.adafruit.com/product/1487)
Put on your sunglasses before wiring up this LED matrix - 64 eye-blistering RGB LEDs adorn the NeoMatrix for a blast of configurable color. Arranged in an 8x8 matrix, each pixel is individually addressable. Only one microcontroller pin is required to control all the LEDs, and you get 24 bit...

In Stock
[Buy Now](https://www.adafruit.com/product/1487)
[Related Guides to the Product](https://learn.adafruit.com/products/1487/guides)
### USB Battery Pack for Raspberry Pi - 10000mAh - 2 x 5V outputs

[USB Battery Pack for Raspberry Pi - 10000mAh - 2 x 5V outputs](https://www.adafruit.com/product/1566)
A large-sized rechargeable battery pack for your [Raspberry Pi](http://www.adafruit.com/raspberrypi) (or [Arduino](http://www.adafruit.com/arduino), or [Propeller](http://www.adafruit.com/category/26), or anything else that uses 5V!). This pack is intended for...

In Stock
[Buy Now](https://www.adafruit.com/product/1566)
[Related Guides to the Product](https://learn.adafruit.com/products/1566/guides)
### 5V 2A Switching Power Supply w/ USB-A Connector

[5V 2A Switching Power Supply w/ USB-A Connector](https://www.adafruit.com/product/1994)
Our 5V 2A USB power adapter is the perfect choice for powering single-board computers like Raspberry Pi, BeagleBone, or anything else that's power-hungry!

This adapter was specifically designed to provide 5.25V, not 5V, but we still call it a 5V USB adapter. We did this on purpose to...

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

## Related Guides

- [MicroPython Displays: Drawing Text](https://learn.adafruit.com/micropython-displays-drawing-text.md)
- [Adafruit NeoPixel Überguide](https://learn.adafruit.com/adafruit-neopixel-uberguide.md)
- [The PICsellator](https://learn.adafruit.com/the-picsellator.md)
- [Festive Feather Holiday Lights](https://learn.adafruit.com/festive-feather-holiday-lights.md)
- [Square NeoPixel Display with Black LED Acrylic](https://learn.adafruit.com/sqaure-neopixel-display-with-black-led-acrylic.md)
- [LED Art with Fadecandy](https://learn.adafruit.com/led-art-with-fadecandy.md)
- [Adafruit Sparkle Motion Mini](https://learn.adafruit.com/adafruit-sparkle-motion-mini.md)
- [Using NeoPixels with Netduino Plus 2](https://learn.adafruit.com/using-neopixels-with-netduino.md)
- [Easy NeoPixel Graphics with the CircuitPython Pixel Framebuf Library](https://learn.adafruit.com/easy-neopixel-graphics-with-the-circuitpython-pixel-framebuf-library.md)
- [MicroPython Displays: Drawing Shapes](https://learn.adafruit.com/micropython-displays-drawing-shapes.md)
- [Smart Bathroom App](https://learn.adafruit.com/smart-bathroom-app.md)
- [Adafruit Sparkle Motion](https://learn.adafruit.com/adafruit-sparkle-motion.md)
- [NeoPixels on Raspberry Pi](https://learn.adafruit.com/neopixels-on-raspberry-pi.md)
- [Multi-tasking the Arduino - Part 3](https://learn.adafruit.com/multi-tasking-the-arduino-part-3.md)
- [NeoMatrix 8x8 Word Clock](https://learn.adafruit.com/neomatrix-8x8-word-clock.md)
