# A NeoPixel Blinkendisc

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/025/614/medium800thumb/leds_animation.jpg?1448318174)

I played a lot of&nbsp;[Ultimate](http://en.wikipedia.org/wiki/Ultimate_%28sport%29) in college, and I've wanted to build a programmable, sensor-equipped disc ever since. This project is intended as a basic starting point for DIY disc projects: It can be programmed in the Arduino IDE or with CircuitPython, it looks cool when flying, and it responds to being thrown and caught.

Info: 

You'll need:

- [GEMMA](https://www.adafruit.com/product/1222) or [GEMMA&nbsp;M0](https://www.adafruit.com/product/3501)&nbsp;microcontroller (M0 is recommended)
- [NeoPixel Ring - 24 x WS2812 5050 RGB LED](https://www.adafruit.com/products/1586)
- [150 mAh LiPo battery](https://www.adafruit.com/products/1317) (get a few)
- [Adafruit Micro Lipo w/MicroUSB Jack - USB LiIon/LiPoly charger](https://www.adafruit.com/products/1904) or similar charger
- [Silicone Cover Stranded-Core Wire](https://www.adafruit.com/products/1970) in 4-5 colors - nearly anything will probably work here, but this stuff is flexible and easy to work with
- [Fast Vibration Sensor Switch](https://www.adafruit.com/products/1766)
- Soldering iron
- Utility knife / X-Acto /&nbsp; razor
- Hot glue / hot glue gun
- A handful of rubber or nylon washers for spacing
- E6000 Adhesive - available from Amazon or most decent hardware stores (I get mine at [McGuckin Hardware](https://store.mcguckin.com/inet/home.html))
- Sturdy velcro squares or similar fasteners for battery, battery cable, and counterweight
- A desktop computer running the Arduino IDE, version 1.6.4 or later
- A micro-B USB cable

Assembly is fairly simple and goes quickly, but you'll want to factor in at least 24 hours of curing time for the E6000.

# A NeoPixel Blinkendisc

## Hardware: Disc

![](https://cdn-learn.adafruit.com/assets/assets/000/025/585/medium800/leds_IMG_5776.jpg?1432154949)

## Choosing a Disc
As afficionados probably know, Frisbee is a trademark owned by Wham-O, while a lot of the better options in the "flying plastic disc" market are sold by companies like Discraft.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/587/medium800/leds_IMG_5870.jpg?1432155144)

The&nbsp;[Flashflight](http://flashflight.com/) Disc-O, designed in Boulder, CO and widely distributed by [Nite Ize](https://www.niteize.com/), is a good quality disc with an RGB LED and a couple of coin cells mounted in the center. A handful of fiber-optic light pipes run from the center out to the edges. At 185g, it weighs a bit more than a standard Ultimate disc, but generally flies well and has a good feel.

I decided to modify one of these since I figured I could repurpose the light pipes. They already look pretty good, after all:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/586/medium800/leds_IMG_5874.jpg?1432155008)

Any decent disc should work for this project, but something that will diffuse or scatter light will look the coolest.

## Disc Prep
The Flashflight has an enclosure for its LED and batteries mounted on the underside. This also doubles as a power button.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/589/medium800/leds_IMG_5622.jpg?1432155971)

First, pry the lid / button case off. You should be able to do this with your bare hands, but it's fairly stiff.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/590/medium800/leds_IMG_5623.jpg?1432156278)

Remove the LED assembly, and you'll be left with a hard plastic enclosure, attached to the disc with little plastic globs / studs / rivets.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/591/medium800/leds_IMG_5627.jpg?1432156374)

Get a utility knife or X-Acto and (carefully!) cut through the globs of plastic.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/602/medium800/leds_IMG_5919.jpg?1432321393)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/603/medium800/leds_IMG_5923.jpg?1432321437)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/592/medium800/leds_IMG_5630.jpg?1432157144)

Next, we'll put together the electronics and make sure a basic lighting sketch is working before attaching to the disc.

# A NeoPixel Blinkendisc

## Hardware: Blinkenlights

## Gemma & NeoPixel Ring
Info: 

Start by soldering the NeoPixel ring to the Gemma like so:

- **GND** → **GND**
- **D0** → **Data Input**
- **Vout** → **Pwr**

![](https://cdn-learn.adafruit.com/assets/assets/000/047/121/medium800/led_pixels_blinkendisc-no-sensor_bb.png?1507587863)

[Download Fritzing File NeoPixel_Blinkendisc.fzz](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Gemma/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc_Sensor.fzz)
You'll want to arrange things so that the top of the Gemma (the side with the LEDs, button, switch, USB, and battery connector) faces _out_ from the disc, while the top of the NeoPixel ring (the side with the LEDs on it) can make contact with the disc. It's helpful to lay things out on the disc first to get a sense of what this looks like:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/604/medium800/leds_IMG_5927.jpg?1432321620)

You'll want a little bit of slack in the wire for positioning, but not too much. I wound up with longer wire than I strictly needed.

Push the wires through the NeoPixel ring from the top (the LED side) and solder them from the bottom. Once in place, they should fit in-between the LEDs on the top. I did the same with the Gemma on my first disc, though it might be safer to run them up from underneath and keep the profile lower.

## Vibration Switch
Next, add the vibration switch like so:

- **GND** → **One leg of sensor**  
- **D1** → **Other leg of sensor**  

![](https://cdn-learn.adafruit.com/assets/assets/000/047/123/medium800/led_pixels_blinkendisc-with-sensor_bb.png?1507588090)

The plan is to tuck the sensor in between the Gemma and the NeoPixel ring and apply hot glue, so don't use too much wire. I wound up using the end of [a jumper wire](https://www.adafruit.com/products/266) for the stiffer leg of the sensor, and putting a bit of heat shrink around a blob of solder on the other, flimsier leg, but this is probably overcomplicated. The main thing is that you want connections which will hold up as the disc is thrown.

[Download Fritzing File NeoPixel_Blinkendisc_Sensor.fzz](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc_Sensor.fzz)
# A NeoPixel Blinkendisc

## Arduino Code

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/025/606/medium800/leds_IMG_5751.jpg?1432326080)

With the circuit fully assembled, you're ready for some code.

## Arduino IDE Setup
First, if you haven't programmed your Gemma before, you'll need to get the IDE up and running. Check out the introductory guide, particularly the sections on drivers and IDE setup:

[Introduction to Gemma M0](https://learn.adafruit.com/adafruit-gemma-m0)
or

[Introduction to Gemma (Classic)](https://learn.adafruit.com/introducing-gemma/introduction)
Once you've got the IDE configured, make sure you've got the Adafruit NeoPixel library installed. There's a full guide here:

[Adafruit NeoPixel Überguide - Arduino Library](https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library)
You should be able to install this using the LIbrary Manager in the IDE - just do **Sketch** -\> **Include Library** -\> **Manage Libraries...**

![](https://cdn-learn.adafruit.com/assets/assets/000/025/599/medium800/leds_manage_libraries_menu.png?1432313853)

Select "All" in the Type dropdown, and search for "neopixel", then click the row and you should get an "Install" button.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/600/medium800/leds_library_manager_neopixel.png?1432313886)

Again, if you're having trouble here, refer to [the full NeoPixel guide](../../../../adafruit-neopixel-uberguide/overview).

## Blinkendisc Sketch
Next, copy and paste the following code in a new sketch:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Gemma/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc.ino

From the&nbsp; **Tools→Board** &nbsp;menu, select&nbsp;the&nbsp;device you are using: **&nbsp;**

- **Adafruit Gemma M0**
- **Adafruit Gemma 8 MHz** &nbsp;
- Connect the USB cable between the computer and your device. The original Gemma (8 MHz) need the reset button pressed on the board, then click the upload button (right arrow icon) in the Arduino IDE. You do not need to press the reset on the newer Gemma M0 or Trinket M0.

If all went well, the NeoPixel ring will start a rotating pattern with 4 LEDs lit at once, and tapping the vibration sensor will change the colors.

Info: 

Once the sketch is running, it's probably a good idea to connect a charged LiPo to the Gemma and disconnect the USB cable to make sure the whole thing runs on battery power.

# A NeoPixel Blinkendisc

## CircuitPython Code

![](https://cdn-learn.adafruit.com/assets/assets/000/046/588/medium800/led_pixels_CircuitPython-Gemma-w-Blinka.jpg?1505601755)

 **GEMMA&nbsp;M0** boards can&nbsp;run **CircuitPython** &nbsp;— a different approach to programming compared to Arduino sketches. In fact, **CircuitPython comes&nbsp;factory pre-loaded on GEMMA&nbsp;M0**. If you’ve overwritten it with an Arduino sketch, or just want to learn the basics of setting up and using CircuitPython, this is explained in the [**Adafruit GEMMA&nbsp;M0 guide**](../../../../adafruit-gemma-m0/circuitpython-setup-1).

Info: 

Below is CircuitPython code that works&nbsp;similarly (though not exactly the same) as the Arduino sketch shown on a prior page. To use this, plug the GEMMA M0 into USB…it should show up on your computer as a small **flash drive** …then edit the file “ **main.py** ” with your text editor of choice. Select and copy the code below and paste it into that file, **entirely replacing its contents** (don’t mix it in with lingering bits of old code). When you save the file, the code should **start running almost immediately** &nbsp;(if not, see notes at the bottom of this page).

**If GEMMA M0 doesn’t show up as a&nbsp;drive, follow the GEMMA M0 guide link above to prepare the board for CircuitPython.**

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

This code requires the **neopixel.py** library. A factory-fresh board will have this already installed. If you’ve just reloaded the board with CircuitPython, create the “lib” directory and then [download neopixel.py from Github](https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel).

&nbsp;

# A NeoPixel Blinkendisc

## Blinkendisc Sketch Features

The Blinkendisc sketch as-written doesn't do _too_ much, but it does offer a handful of configuration constants that you can tweak to change the behavior of the disc without rewriting the code.

## Building Frames of Animation
First, let's look at the basic idea that drives the sketch. Here's a really simplified version of the `loop()` function:

```auto
void loop() {
  uint32_t t;

  while(((t = millis()) - last_frame) <= frame_len) {
    if(!digitalRead(VIBRATION_PIN)) { // Vibration sensor activated?
      last_vibration = t;             // Save last vibration time
    }
  }

  // Make any changes that need t, last_frame or last_vibration here.

  // Draw new frame of pixel animation here.

  pixels.show();
  last_frame = t;
}
```

This `loop()` will get called over and over again for as long as the Gemma runs. Each time through, we:

1. Set `t` to the current return value of `millis()`, which should tell us the number of milliseconds since the sketch started.
2. Repeatedly&nbsp;compare this against the time the last animation frame was drawn (`last_frame`). While we're waiting for the correct time interval to have passed…
3. Use `if(!digitalRead(VIBRATION_PIN)) { ... }` to check for a vibration, and if we got one, set `last_vibration` to `t`. (The full Arduino sketch also uses this opportunity to pick a new random color.)

At this point we know:

- How long ago we last advanced a frame.
- How long ago we last detected a vibration.

The rest of the code makes decisions about what to do with this information, and translates those decisions into lit-up LEDs on the NeoPixel ring. This all happens fast enough that the vibration switch should be responsive and the animation fairly smooth.

## Configuration Constants
If you look at the top of the sketch, you'll see the following configuration values:

```auto
#define NUM_LEDS              24 // 24 LED NeoPixel ring
#define NEOPIXEL_PIN           0 // Pin D0 on Gemma
#define VIBRATION_PIN          1 // Pin D1 on Gemma
#define ANALOG_RANDOMNESS_PIN A1 // Not connected to anything

#define DEFAULT_FRAME_LEN     60
#define MAX_FRAME_LEN        255
#define MIN_FRAME_LEN          5
#define COOLDOWN_AT         2000
#define DIM_AT              2500
#define BRIGHTNESS_HIGH      128
#define BRIGHTNESS_LOW        32
```

The first four&nbsp;are used to set up hardware pins on the Gemma, and should be left alone unless you wire things up differently or translate the sketch to another board with a different layout.

The rest offer various ways to change the timing and brightness of the animation:

# A NeoPixel Blinkendisc

## Final Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/025/616/medium800thumb/leds_animation2.jpg?1448318184)

Once you're confident that the hardware is working and programmed, it's time to attach it to the disc. You'll need:

- A tube of E6000 adhesive
- 1-2 non-conductive washers or spacers, rubber or nylon, to raise the Gemma above the level of the NeoPixel ring so that the battery and USB cable can still be connected
- Gemma + NeoPixel + vibration switch assembly
- Random small, flat object (a washer may work well) for counterweighting battery
- Sturdy self-adhesive velcro patches (or, in a pinch, tape) for battery and counterweight

## Disc Prep
Start by levelling the area the ring will occupy in the center of the disc (cutting off any bits of plastic that project too far from the surface), and trimming the ends of the light pipes and the channels they snap into (if using a Flashflight) to line up with the LEDs on the NeoPixel ring.

I found it easiest to eyeball the alignment of the ring and score the pipes/channels with a knife, then use a pair of scissors to snip the pipes. Be a little careful with this part - the light pipes are more brittle than the plastic that makes up the rest of the disc, but they should bend far enough to be easily cut and go back into place without much trouble.

This step isn't strictly necessary, but the final disc will look a lot cooler if the LEDs are in proximity to the ends of the light pipes.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/607/medium800/leds_IMG_5928.jpg?1432326666)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/608/medium800/leds_IMG_5929.jpg?1432326710)

## Attaching Gemma & NeoPixel Ring with E6000
Warning: 

First, apply E6000 to the washers and Gemma, centering it in the disc. Once that's in place, lay down a thick bead in the footprint of the NeoPixel ring, and press it firmly into place. This photo, minus the vibration switch, shows the positioning you're looking for:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/609/medium800/leds_IMG_5754.jpg?1432327644)

Think of the E6000 as a structural element - it should hold the ring firmly into place, and partly function to diffuse the light from the LEDs.

Once this is done, set the disc aside on a flat surface and **do not touch it for 24 hours**. Seriously, come back in a day.

## Attach Battery and Counterweight
Now you need power. To attach the battery, I used self-adhesive velcro squares - one side on the battery, one side on the disc, positioned like so:

![](https://cdn-learn.adafruit.com/assets/assets/000/025/610/medium800/leds_IMG_5761.jpg?1432328156)

I was worried about the battery wires snagging on something, so I added an extra square with some plastic over the adhesive on the top piece to hold them in place.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/611/medium800/leds_IMG_5756.jpg?1432328363)

As soon as I tested this in flight, I realized the off-center weight was introducing a predictable wobble, so I added some more velcro with a small piece of wood on the opposite side to counterbalance the battery. (You may need to experiment with placement.)

![](https://cdn-learn.adafruit.com/assets/assets/000/025/612/medium800/leds_IMG_5778.jpg?1432328667)

## Slather Some Hot Glue on There
Once I'd flight-tested the disc and was sure I was happy with the hardware layout, I added a healthy dose of hot glue to hold wires and the vibration sensor in place.

![](https://cdn-learn.adafruit.com/assets/assets/000/025/613/medium800/leds_IMG_5918.jpg?1432328796)

# A NeoPixel Blinkendisc

## Directions for Further Research

So now we have a disc with programmable LEDs which responds, at least in a rudimentary fashion, to its environment.

This is all well and good, but as anyone with much experience throwing a disc can probably attest, the physical end result leaves something to be desired. The electronics will likely survive a casual game of catch, as long as the participants have a light touch and don't [pancake the disc too hard](http://www.ultimatehandbook.com/uh/basics_catching.html), and it looks good in the dark, but we're a long ways from a finished piece of serious athletic gear. The rigors of a real Ultimate game would probably destroy the blinkendisc in a couple of plays.

So where to from here? Well, I have an entire research agenda:

1. Design and 3D print an enclosure for the electronics that will stand up to mud puddles, random concrete obstacles, actual Ultimate games, and the typical antics of Ultimate players.
2. Incorporate additional sensor input and some form of wireless communication.
3. Add more blinkenlights, because life is too short to blink in moderation.
4. Design an interesting game mechanic that relies on accumulating state on the disc itself.

Stay tuned!


## Featured Products

### Adafruit GEMMA M0 - Miniature wearable electronic platform

[Adafruit GEMMA M0 - Miniature wearable electronic platform](https://www.adafruit.com/product/3501)
The **Adafruit Gemma M0** is a super small microcontroller board, with just enough built-in to create many simple projects. It may look small and cute: round, about the size of a quarter, with friendly alligator-clip sew pads. But do not be fooled! The Gemma M0 is incredibly...

In Stock
[Buy Now](https://www.adafruit.com/product/3501)
[Related Guides to the Product](https://learn.adafruit.com/products/3501/guides)
### Adafruit GEMMA v2 - Miniature wearable electronic platform

[Adafruit GEMMA v2 - Miniature wearable electronic platform](https://www.adafruit.com/product/1222)
 **Deprecation Warning: The Gemma bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Gemma so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1222)
[Related Guides to the Product](https://learn.adafruit.com/products/1222/guides)
### NeoPixel Ring - 24 x 5050 RGB LED with Integrated Drivers

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

In Stock
[Buy Now](https://www.adafruit.com/product/1586)
[Related Guides to the Product](https://learn.adafruit.com/products/1586/guides)
### Fast Vibration Sensor Switch (Easy to trigger)

[Fast Vibration Sensor Switch (Easy to trigger)](https://www.adafruit.com/product/1766)
The "poor man's" accelerometer/motion sensor! These spring-vibration switches are **high sensitivity** non-directional vibration induced trigger switches. Inside is a very soft spring coiled around a long metal pin. When the switch is moved, the spring touches the...

In Stock
[Buy Now](https://www.adafruit.com/product/1766)
[Related Guides to the Product](https://learn.adafruit.com/products/1766/guides)
### Silicone Cover Stranded-Core Wire - 26AWG in Various Colors

[Silicone Cover Stranded-Core Wire - 26AWG in Various Colors](https://www.adafruit.com/product/1970)
Silicone-sheathing wire is super-flexible and soft, and it's also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness...

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

[Lithium Ion Polymer Battery - 3.7v 150mAh](https://www.adafruit.com/product/1317)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 150mAh for a total of about 0.6 Wh. If you need a larger battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1317)
[Related Guides to the Product](https://learn.adafruit.com/products/1317/guides)
### Adafruit Micro-Lipo Charger for LiPo/LiIon Batt w/MicroUSB Jack

[Adafruit Micro-Lipo Charger for LiPo/LiIon Batt w/MicroUSB Jack](https://www.adafruit.com/product/1904)
Oh so handy, this little lipo charger is so small and easy to use you can keep it on your desk or mount it easily into any project! Simply plug it via any MicroUSB cable into a USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end....

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

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

Approximately 3 feet / 1 meter long

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

## Related Guides

- [CurieBot: Arduino 101 Mini Robot Rover](https://learn.adafruit.com/curiebot-arduino-101-mini-robot-rover.md)
- [Trinket / Gemma Blinky Eyes](https://learn.adafruit.com/trinket-gemma-blinky-eyes.md)
- [NeoPixel Tiara](https://learn.adafruit.com/neopixel-tiara.md)
- [Hanukkah MakeCode Menorah Sweater](https://learn.adafruit.com/hanukkah-menorah-sweater.md)
- [Annoy-O-Matic Sound Prank Device](https://learn.adafruit.com/annoy-o-matic-sound-prank-device.md)
- [NeoPixel Ring Clock](https://learn.adafruit.com/neopixel-ring-clock.md)
- [NeoPixel Rotary Fidget](https://learn.adafruit.com/neopixel-rotary-fidget.md)
- [NeoPixel Ring Lamp](https://learn.adafruit.com/neopixel-ring-lamp.md)
- [Gemma Color Touch Pendant Necklace](https://learn.adafruit.com/gemma-color-touch-pendant-necklace.md)
- [3D Printed Daft Punk Helmet with Bluetooth ](https://learn.adafruit.com/3d-printed-daft-punk-helmet-with-bluetooth.md)
- [NeoPixel Flame Torch](https://learn.adafruit.com/neopixel-flame-torch.md)
- [GEMMA Hoop Earrings](https://learn.adafruit.com/gemma-hoop-earrings.md)
- [Best Beginner Boards for Teachers](https://learn.adafruit.com/best-beginner-boards-for-teachers.md)
- [Close Encounters Hat](https://learn.adafruit.com/close-encounters-hat.md)
- [Hidden Ink UV Message Reader](https://learn.adafruit.com/hidden-ink-uv-message-reader.md)
