# Clockwork Goggles

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/046/934/medium800/adafruit_gemma_PA020082_2k.jpg?1507008992)

Goggles are a great accessory for dressing up your costume -- be it for Halloween or cosplay. There are many styles and genres which can be enhanced by goggles, including cypberpunk, steampunk, dieselpunk, Burning Man, mad science, and clockwork, to name a few.

This year, our&nbsp;daughter decided to be a "steampunk girl" for Halloween! So, we decided to dress up&nbsp;her&nbsp;prop costume goggles with some LED rings animated with a sort of clockwork ticking pattern.

Using a **Gemma**  **M0** running [CircuitPython](https://www.adafruit.com/circuitpython)&nbsp;is a&nbsp;great way to drive the pair of 16 **NeoPixel** rings, particularly because [CircuitPython](https://www.adafruit.com/circuitpython)&nbsp;makes it so fast to iterate on color and timing in our program.

Follow along&nbsp;with this simple build&nbsp;to make your own stylish clockwork cog goggles!

https://youtu.be/-CNIp6EtVY8

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/046/905/medium800/adafruit_gemma_PA020006_2k.jpg?1506991440)

In addition to the parts listed here, you will also want some foam stick tape to attach&nbsp;the electronics to your goggles, as well as a small drill bit and drill to run the wiring through.

You'll need a soldering iron and solder, as well as some wire cutters and strippers.

### Part: Adafruit GEMMA M0
quantity: 1
Miniature wearable electronic platform -- CircuitPython capable!
[Adafruit GEMMA M0](https://www.adafruit.com/product/3501)

### Part: NeoPixel Ring - 16 pixel RGB LED
quantity: 2
LED rings with integrated drivers
[NeoPixel Ring - 16 pixel RGB LED](https://www.adafruit.com/product/1463)

### Part: Lithium Ion Polymer Battery
quantity: 1
3.7V 500mAh battery
[Lithium Ion Polymer Battery](https://www.adafruit.com/product/1578)

### Part: Silicone Cover Stranded-Core Wire
quantity: 1
2m of red 26AWG wire
[Silicone Cover Stranded-Core Wire](https://www.adafruit.com/product/1877)

### Part: Silicone Cover Stranded-Core Wire
quantity: 1
2m of black 26AWG wire
[Silicone Cover Stranded-Core Wire](https://www.adafruit.com/product/1881)

### Part: Silicone Cover Stranded-Core Wire
quantity: 1
2m of yellow 26AWG wire
[Silicone Cover Stranded-Core Wire](https://www.adafruit.com/product/1879)

### Part: Silicone Cover Stranded-Core Wire
quantity: 1
2m of green 26AWG wire
[Silicone Cover Stranded-Core Wire](https://www.adafruit.com/product/1880)

### Part: Costume Goggles
quantity: 1
Goggles
[Costume Goggles](https://www.adafruit.com/product/1577)

### Part: USB cable
quantity: 1
A/MicroB for programming the Gemma M0
[USB cable](https://www.adafruit.com/product/592)

Info: 

# Clockwork Goggles

## Assemble Circuit and Goggles

![](https://cdn-learn.adafruit.com/assets/assets/000/046/936/medium800/adafruit_gemma_cogCoggles02.jpg?1507053562)

[cogGoggles.fzz](https://cdn-learn.adafruit.com/assets/assets/000/046/937/original/cogGoggles.fzz?1507053573)
The circuit we'll make is pretty simple. Each **NeoPixel** ring will have three connections to the **Gemma M0** :

- **GND** to **GND**
- **V+** to&nbsp; **VOUT**
- **Digital In** to **D1** or **D0** respectively for the left and right ring

The LiPo battery will provide power to the **Gemma**  **M0** and the **NeoPixels**.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/046/906/medium800/adafruit_gemma_PA020007_2k.jpg?1506991471)

Start by cutting a 6" lengths each of red, black, and yellow wire. Then, cut a 4" length each of red, black, and green wire. Strip a 1/4" of insulation from both ends of each wire.

![](https://cdn-learn.adafruit.com/assets/assets/000/046/907/medium800/adafruit_gemma_PA020004_2k.jpg?1506991513)

Now, solder the 6" wires to the&nbsp;left **NeoPixel** ring, following the guide and circuit diagram from above.

Then, solder the 4" wires to the&nbsp;right **NeoPixel** ring.

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/046/908/medium800/adafruit_gemma_PA020009_2k.jpg?1506991525)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/909/medium800/adafruit_gemma_PA020010_2k.jpg?1506991558)

Drill three holes in each goggle "lens" if you're using molded plastic prop goggles. These need to align with the wire placement of each **NeoPixel** ring.

&nbsp;

Or, if you're using goggles with removable lenses,&nbsp;remove/unscrew them now -- the wires will simple drop inside the goggle "cups".

![adafruit_gemma_PA020011_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/910/medium640/adafruit_gemma_PA020011_2k.jpg?1506991625)

![adafruit_gemma_PA020013_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/911/medium640/adafruit_gemma_PA020013_2k.jpg?1506991634)

![adafruit_gemma_PA020014_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/912/medium640/adafruit_gemma_PA020014_2k.jpg?1506991641)

![adafruit_gemma_PA020015_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/913/medium640/adafruit_gemma_PA020015_2k.jpg?1506991656)

Place each **NeoPixel** ring over the goggle lenses, and pass the wires through to the inside. This is where the **Gemma**  **M0** and battery will live.

![adafruit_gemma_PA020016_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/914/medium640/adafruit_gemma_PA020016_2k.jpg?1506991690)

![adafruit_gemma_PA020017_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/915/medium640/adafruit_gemma_PA020017_2k.jpg?1506991699)

![adafruit_gemma_PA020019_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/916/medium640/adafruit_gemma_PA020019_2k.jpg?1506991706)

![adafruit_gemma_PA020020_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/917/medium640/adafruit_gemma_PA020020_2k.jpg?1506991714)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/919/medium800/adafruit_gemma_PA020028_2k.jpg?1506991826)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/920/medium800/adafruit_gemma_PA020027_2k.jpg?1506991837)

Flip over the goggles, and then solder the wires on as shown in the diagram.

&nbsp;

**NOTE** : the photos show the NeoPixels being powered by the 3.3V pad on the Gemma M0, which works, but soldering to the VOUT is preferable.

![adafruit_gemma_PA020030_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/921/medium640/adafruit_gemma_PA020030_2k.jpg?1506992248)

![adafruit_gemma_PA020034_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/922/medium640/adafruit_gemma_PA020034_2k.jpg?1506992276)

![adafruit_gemma_PA020037_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/923/medium640/adafruit_gemma_PA020037_2k.jpg?1506992287)

![adafruit_gemma_PA020038_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/924/medium640/adafruit_gemma_PA020038_2k.jpg?1506992301)

![adafruit_gemma_PA020039_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/925/medium640/adafruit_gemma_PA020039_2k.jpg?1506992308)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/927/medium800/adafruit_gemma_PA020041_2k.jpg?1506992375)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/926/medium800/adafruit_gemma_PA020042_2k.jpg?1506992372)

Plug in the battery, and then affix the **Gemma**  **M0** , **NeoPixel** rings, and battery to the goggles with double stick foam tape, making sure to leave the on/off switch exposed and the USB port accessible.

![](https://cdn-learn.adafruit.com/assets/assets/000/046/930/medium800/adafruit_gemma_PA020021_2k.jpg?1506992430)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/929/medium800/adafruit_gemma_PA020022_2k.jpg?1506992428)

![](https://cdn-learn.adafruit.com/assets/assets/000/046/928/medium800/adafruit_gemma_PA020023_2k.jpg?1506992426)

Next, you'll plug the **Gemma**  **M0** into your computer with a USB cable and begin programming it!

# Clockwork Goggles

## CircuitPython Setup and Code

![](https://cdn-learn.adafruit.com/assets/assets/000/046/931/medium800/adafruit_gemma_PA020051_2k.jpg?1506992583)

Now it's time to set up the Gemma M0 for use with [CircuitPython](https://www.adafruit.com/circuitpython)&nbsp;and our cog animation code.

If you haven't already, follow [this guide](../../../../adafruit-gemma-m0/circuitpython) to preparing the Gemma M0, including updating it with the latest version of CircuitPython.

After prepping the Gemma M0 to run CircuitPython we'll also need to add a NeoPixel library. [This guide tells you how](../../../../adafruit-gemma-m0/circuitpython-neopixel),&nbsp;as well as providing a good primer on using NeoPixels on the Gemma M0 with **CircuitPython**.

Download the&nbsp; **adafruit-circuitpython-bundle-2.0.0-20170915.zip** &nbsp;(or newer) from the [releases directory](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/) and then unzip it somewhere easy to find, such as your desktop. Then, copy the **neopixel.mpy** file to your **CIRCUITPY** &nbsp; **lib** directory on the Gemma M0.

Finally, trash the **neopixel.py** file that was already in that same **lib** directory.

Once you've got things working, you can edit the **code.py** file on the Gemma M0 to adjust what it actually does. No need for a software IDE, complaining tools, or flashing the chip -- when you code with CircuitPython all you need is a text editor. Edit the code, save it to the Gemma M0, and it immediately runs!

Primary: 

Copy the code from below, and then paste it into your text editor. Then save the file to your Gemma M0 as **code.py**.

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

The code will start running immediately, and the two rings will begin animating!

if you'd like, you can edit the colors and patterns of the cog animation to suit your costume. Look at the comments in the code to see how to make adjustments.

# Clockwork Goggles

## Rock the Goggles

![](https://cdn-learn.adafruit.com/assets/assets/000/046/932/medium800/adafruit_gemma_PA020082_2k.jpg?1507004306)

All that remains is to don the goggles, turn on the switch on the **Gemma**  **M0** , and look the part!

![](https://cdn-learn.adafruit.com/assets/assets/000/046/935/medium800thumb/adafruit_gemma_coggogLoops03.jpg?1507051061)

Any time you want to adjust the animations, you can simply plug in the **Gemma**  **M0** to any computer and tweak the `main.py` file in a text editor!

Or, try to adjust the code so that the **D2** pad on the **Gemma**  **M0** acts as a capacitive touch input button to toggle the different animation patterns.


## 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 Trinket M0 - for use with CircuitPython & Arduino IDE

[Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE](https://www.adafruit.com/product/3500)
The&nbsp;Adafruit Trinket M0 may be small, but do not be fooled by its size! It's a tiny microcontroller board, built around the Atmel ATSAMD21, a little chip with _a lot_ of power. We wanted to design a microcontroller board that was small enough to fit into any project, and low...

In Stock
[Buy Now](https://www.adafruit.com/product/3500)
[Related Guides to the Product](https://learn.adafruit.com/products/3500/guides)
### NeoPixel Ring - 16 x 5050 RGB LED with Integrated Drivers

[NeoPixel Ring - 16 x 5050 RGB LED with Integrated Drivers](https://www.adafruit.com/product/1463)
Round and round and round they go! 16 ultra bright smart LED NeoPixels are arranged in a circle with 1.75" (44.5mm) 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/1463)
[Related Guides to the Product](https://learn.adafruit.com/products/1463/guides)
### Lithium Ion Polymer Battery - 3.7v 500mAh

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

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

[Silicone Cover Stranded-Core Wire - 2m 26AWG Red](https://www.adafruit.com/product/1877)
Silicone-sheathing wire is super-flexible and soft, and its 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 has to...

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

[Silicone Cover Stranded-Core Wire - 2m 26AWG Black](https://www.adafruit.com/product/1881)
Silicone-sheathing wire is super-flexible and soft, and its 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 has to...

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

[Silicone Cover Stranded-Core Wire - 2m 26AWG Yellow](https://www.adafruit.com/product/1879)
Silicone-sheathing wire is super-flexible and soft, and its 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 has to...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1879)
[Related Guides to the Product](https://learn.adafruit.com/products/1879/guides)
### Silicone Cover Stranded-Core Wire - 2m 26AWG Green

[Silicone Cover Stranded-Core Wire - 2m 26AWG Green](https://www.adafruit.com/product/1880)
Silicone-sheathing wire is super-flexible and soft, and its 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 has to...

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

## Related Guides

- [Adafruit Trinket M0](https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino.md)
- [NeoPixel Manicure](https://learn.adafruit.com/neopixel-manicure.md)
- [CircuitPython Media Dial](https://learn.adafruit.com/media-dial.md)
- [Gemma LightTouch](https://learn.adafruit.com/gemma-lighttouch.md)
- [Glowing Fascinator Hat with Gemma M0 and MakeCode](https://learn.adafruit.com/glowing-fascinator-hat-gemma-m0-makecode.md)
- [Adafruit LED Sequins](https://learn.adafruit.com/adafruit-led-sequins.md)
- [Best Beginner Boards for Teachers](https://learn.adafruit.com/best-beginner-boards-for-teachers.md)
- [3D Printed NeoPixel LED Gas Mask](https://learn.adafruit.com/3d-printed-el-wire-laser-neopixel-led-gas-mask.md)
- [Light-Activated Pixel Heart](https://learn.adafruit.com/light-activated-pixel-heart.md)
- [NeoPixel Ring Lamp](https://learn.adafruit.com/neopixel-ring-lamp.md)
- [DIY Thermal Light Painting - Heat Map Photography](https://learn.adafruit.com/diy-flir-light-painting-heat-map-photography.md)
- [NeoPixels on Raspberry Pi](https://learn.adafruit.com/neopixels-on-raspberry-pi.md)
- [Sipping Power With NeoPixels](https://learn.adafruit.com/sipping-power-with-neopixels.md)
- [MakeCode Maker](https://learn.adafruit.com/makecode-maker.md)
- [NeoPixie Dust Bag](https://learn.adafruit.com/neopixel-pixie-dust-bag.md)
- [Zelda Guardian Robot Terrako Companion](https://learn.adafruit.com/terrako.md)
