Clockwork Goggles. Created by John Park. Last updated on :03:10 PM UTC

Similar documents
NeoPixel Basketball Hoop

Mystical LED Halloween Hood

Adafruit LED Sequins. Created by Becky Stern. Last updated on :02:00 AM UTC

NeoPixel Ring Bangle Bracelet

Neon LED Signs. Created by John Park. Last updated on :11:09 PM UTC

Wind Blowing Emoji Prop

Jewel Hair Stick. Created by Leslie Birch. Last updated on :47:17 PM UTC

Reindeer Mask with Animated Eyes

NeoPixie Dust Bag with Circuit Playground Express

NeoPixel Bike Light. Created by Ruiz Brothers. Last updated on :43:46 PM UTC

NeoPixel Punk Collar. Created by Becky Stern. Last updated on :41:18 PM UTC

NeoPixel Manicure. Created by Sophy Wong. Last updated on :50:38 PM UTC

Feather Weather Lamp. Created by Ruiz Brothers. Last updated on :54:26 PM UTC

Kaleidoscope Eyes (Trinket-Powered NeoPixel LED Ring Goggles)

NeoPixel LED Cortana Costume

NeoPixel Fairy Crown. Created by Erin St Blaine. Last updated on :22:47 AM UTC

PyPortal NeoPixel Color Picker Created by Kattni Rembor. Last updated on :42:41 PM UTC

Guardian Shield+ Zelda Breath of the Wild

3D Printed Camera LED Ring

Portable Apple Watch Charger

Cyberpunk Spikes. Created by Becky Stern. Last updated on :07:06 PM UTC

Bunny Ears with MakeCode

Milk Jug Glow Skull. Created by John Park. Last updated on :28:36 PM UTC

Celebration Spectacles

PyPortal View Master Created by Ruiz Brothers. Last updated on :51:28 AM UTC

Interior Purse Light. Created by Becky Stern. Last updated on :41:08 PM UTC

Crawling Animatronic Hand

Solar Boost Bag. Created by Becky Stern. Last updated on :44:55 PM UTC

Light-Up Angler Fish Embroidery

Adabot Operation Game

FLORA Pixel Brooch. Created by Becky Stern. Last updated on :19:07 PM EST

Adafruit Capacitive Touch Sensor Breakouts

LED Breath Stats Mask

Slider Crank Mechanism -- from Cardboard and Craft Sticks

Interactive Gift Box. Created by codingpro. Last updated on :47:40 AM UTC

UFO Flying Saucer with Circuit Playground Express

Infinity Mirror Valentine's Candy Box

Adafruit LED Sequins. Created by Becky Stern. Last updated on :00:06 PM EST

Bluetooth Controlled NeoPixel Headphones

LED Eyes. Created by Ruiz Brothers. Last updated on :50:55 AM UTC

Lie Ren's Stormflower Gun Blade

FLORA TV-B-Gone. Created by Becky Stern. Last updated on :32:57 PM UTC

Android GBoard Morse Code Control with Circuit Playground Express

Pushrod Garage. Created by John Park. Last updated on :07:30 PM UTC

Ping Pong Ball Launcher

NeoMatrix 8x8 Word Clock

Sewable NeoPixels. Created by Becky Stern. Last updated on :50:14 PM EDT

7 Portable Multitouch Raspberry Pi Tablet

Easy Sparkle Pocket T-Shirt

'Sup Brows. Created by Kate Hartman. Last updated on :52:04 PM UTC

3D Printed LED Goggles

Getting Started with FLORA

Bike Wheel POV Display

CircuitPython Media Dial

Trinket NeoPixel LED Longboard

Con Badge with Circuit Playground Express

Getting Started with FLORA

ISS Pin. Created by Leslie Birch. Last updated on :27:30 PM UTC

Getting Started with FLORA

Toy Car Speed Timer. Created by Kirby Griese. Last updated on :13:49 PM UTC

Simple LED Unicorn Horn

Audio Prank Gift Box. Created by Becky Stern. Last updated on :46:15 PM UTC

Crickit Dancing Marionette Kit Created by Dano Wall. Last updated on :03:11 PM UTC

Circuit Playground Express Head-Tilt Ears

Chirping Plush Owl Toy

Snake Charmer Box. Created by Dano Wall. Last updated on :07:25 PM UTC

3D Printed Bone Conduction Transducer Box

3D Printed LED Buckle

Paper Airplane Launcher

Monochrome OLED Breakouts

Data Logging with Feather and CircuitPython

FPV Mini Display. Created by Ruiz Brothers. Last updated on :00:18 PM UTC

Adafruit PowerBoost 500 Shield

BLE Light Switch with Feather nrf52840 and Crickit

Circuit Playground Combadge

Mad Science Test Tube Rack

Alohamora Bottle. Created by Erin St Blaine. Last updated on :58:53 PM UTC

Bandolier of Light. Created by Becky Stern. Last updated on :16:17 PM EST

CircuitPython Snow Globe

Crawling Baby Sea Turtle Robot

Luminous LED Flowers. Created by Becky Stern. Last updated on :47:44 PM UTC

FLORA and GEMMA ICSP. Created by Becky Stern. Last updated on :42:16 PM UTC

Crickit Carnival Bumper Bot

Trash Panda. Created by Dano Wall. Last updated on :30:46 AM UTC

HalloWing Jump Scare Trap

Phone-Activated Talking Dog Collar

A NeoPixel Pomodoro Timer

LED NeoPixel Corset with Circuit Playground Express and

Adafruit APDS9960 breakout

Magical Mistletoe. Created by Leslie Birch. Last updated on :45:29 PM UTC

No-Sew LED Wristband. Created by Kathy Ceceri. Last updated on :23:40 PM UTC

Adafruit TPL5110 Power Timer Breakout

Flora Brake Light Backpack

Camera LED Ring Light

Circuit Playground Express Laser Tag

i2c/spi LCD Backpack Created by lady ada Last updated on :11:04 PM UTC

7" Portable HDMI Monitor

Circuit Playground Yoyo

Sword & Wand Prop Effects with Circuit Playground

Hammer Time Mini Golf Hazard with Crickit

Transcription:

Clockwork Goggles Created by John Park Last updated on 2018-08-22 04:03:10 PM UTC

Guide Contents Guide Contents Overview Assemble Circuit and Goggles CircuitPython Setup and Code Rock the Goggles 2 3 6 18 21 Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 2 of 22

Overview 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 daughter decided to be a "steampunk girl" for Halloween! So, we decided to dress up her prop costume goggles with some LED rings animated with a sort of clockwork ticking pattern. Using a Gemma M0 running CircuitPython (https://adafru.it/zb0) is a great way to drive the pair of 16 NeoPixel rings, particularly because CircuitPython (https://adafru.it/zb0) makes it so fast to iterate on color and timing in our program. Follow along with this simple build to make your own stylish clockwork cog goggles! You can supply your own goggles, or pick up a set of welding-style costume goggles in the Adafruit store. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 3 of 22

In addition to the parts listed here, you will also want some foam stick tape to attach 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. 1 x Adafruit GEMMA M0 Miniature wearable electronic platform -- CircuitPython capable! ADD TO CART 2 x NeoPixel Ring - 16 pixel RGB LED LED rings with integrated drivers ADD TO CART 1 x Lithium Ion Polymer Battery 3.7V 500mAh battery ADD TO CART 1 x Silicone Cover Stranded-Core Wire 2m of red 26AWG wire ADD TO CART 1 x Silicone Cover Stranded-Core Wire 2m of black 26AWG wire ADD TO CART 1 x Silicone Cover Stranded-Core Wire 2m of yellow 26AWG wire ADD TO CART Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 4 of 22

1 x Silicone Cover Stranded-Core Wire 2m of green 26AWG wire ADD TO CART 1 x Costume Goggles Goggles ADD TO CART 1 x USB cable A/MicroB for programming the Gemma M0 ADD TO CART The Trinket M0 is another great choice for this project, particularly if you plan to add a few more buttons or sensors, since it has more IO pins available. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 5 of 22

Assemble Circuit and Goggles https://adafru.it/zal https://adafru.it/zal The circuit we'll make is pretty simple. Each NeoPixel ring will have three connections to the Gemma M0: GND to GND V+ to 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. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 6 of 22

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. Now, solder the 6" wires to the left NeoPixel ring, following the guide and circuit diagram from above. Then, solder the 4" wires to the right NeoPixel ring. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 7 of 22

The "LEFT" and "RIGHT" sides are relative to the goggles while being worn. Drill three holes in each goggle "lens" if you're using Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 8 of 22

molded plastic prop goggles. These need to align with the wire placement of each NeoPixel ring. Or, if you're using goggles with removable lenses, remove/unscrew them now -- the wires will simple drop inside the goggle "cups". Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 9 of 22

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 Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 10 of 22

Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 11 of 22

Flip over the goggles, and then solder the wires on as shown in the diagram. 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 Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 12 of 22

Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 13 of 22

Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 14 of 22

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. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 15 of 22

Next, you'll plug the Gemma M0 into your computer with a USB cable and begin programming it! Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 16 of 22

CircuitPython Setup and Code Now it's time to set up the Gemma M0 for use with CircuitPython (https://adafru.it/zb0) and our cog animation code. If you haven't already, follow this guide (https://adafru.it/zal) 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 (https://adafru.it/zam), as well as providing a good primer on using NeoPixels on the Gemma M0 with CircuitPython. Download the adafruit-circuitpython-bundle-2.0.0-20170915.zip (or newer) from the releases directory (https://adafru.it/zb- )and then unzip it somewhere easy to find, such as your desktop. Then, copy the neopixel.mpy file to your CIRCUITPY's 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 main.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! The incredible ease of editing files, even when you're on the go, makes Gemma M0 running CircuitPython the perfect combination for cosplay effects and props! Copy the code from below, and then paste it into your text editor. Then save the file to your Gemma M0 as main.py. # CircuitPython Gemma Gear goggles # uses two 16 NeoPixel rings (RGBW) Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 17 of 22

# connected to Gemma M0 powered by LiPo battery import time import board import neopixel pixpinleft = board.d1 # Data In attached to Gemma pin D1 pixpinright = board.d0 # Data In attached to Gemma pin D0 numpix = 16 # uncomment the lines below for RGB NeoPixels stripleft = neopixel.neopixel(pixpinleft, numpix, bpp=3, brightness=.18, auto_write=false) stripright = neopixel.neopixel(pixpinright, numpix, bpp=3, brightness=.18, auto_write=false) # Use these lines for RGBW NeoPixels # stripleft = neopixel.neopixel(pixpinleft, numpix, bpp=4, brightness=.18, # auto_write=false) # stripright = neopixel.neopixel(pixpinright, numpix, bpp=4, brightness=.18, # auto_write=false) def cog(pos): # Input a value 0 to 255 to get a color value. # Note: switch the commented lines below if using RGB vs. RGBW NeoPixles if (pos < 8) or (pos > 250): # return (120, 0, 0, 0) #first color, red: for RGBW NeoPixels return (120, 0, 0) # first color, red: for RGB NeoPixels if pos < 85: return (int(pos * 3), int(255 - (pos * 3)), 0) # return (125, 35, 0, 0) #second color, brass: for RGBW NeoPixels # return (125, 35, 0) # second color, brass: for RGB NeoPixels elif pos < 170: pos -= 85 # return (int(255 - pos*3), 0, int(pos*3), 0)#: for RGBW NeoPixels return (int(255 - pos * 3), 0, int(pos * 3)) # : for RGB NeoPixels else: pos -= 170 # return (0, int(pos*3), int(255 - pos*3), 0)#: for RGBW NeoPixels return (0, int(pos * 3), int(255 - pos * 3)) # : for RGB NeoPixels def brass_cycle(wait, patternl, patternr): # patterns do different things, try: # 1 blink # 24 chase w pause # 64 chase # 96 parial chase # 128 half turn # 230 quarter turn w blink # 256 quarter turn for j in range(255): for i in range(len(stripleft)): idxl = int((i * patternl / len(stripleft)) + j) stripleft[i] = cog(idxl & 64) # sets the second (brass) color idxr = int((i * patternr / len(stripright)) + j) stripright[i] = cog(idxr & 64) # sets the second (brass) color Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 18 of 22

stripright[i] = cog(idxr & 64) # sets the second (brass) color stripleft.show() stripright.show() time.sleep(wait) while True: brass_cycle(0.01, 256, 24) # brass color cycle with 1ms delay per step # patternl, patternr 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. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 19 of 22

Rock the Goggles All that remains is to don the goggles, turn on the switch on the Gemma M0, and look the part! 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! Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 20 of 22

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. Adafruit Industries https://learn.adafruit.com/gemma_m0_clockwork_goggles Page 21 of 22