NeoPixie Dust Bag with Circuit Playground Express

Similar documents
Wind Blowing Emoji Prop

Sword & Wand Prop Effects with Circuit Playground

Circuit Playground Express Laser Tag

Bunny Ears with MakeCode

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

Con Badge with Circuit Playground Express

Slider Crank Mechanism -- from Cardboard and Craft Sticks

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

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

Adabot Operation Game

Steven Universe Cosplay Shirt & Gem Created by Erin St Blaine. Last updated on :54:25 PM UTC

Infinity Mirror Valentine's Candy Box

Crawling Animatronic Hand

Easy Sparkle Pocket T-Shirt

LED NeoPixel Corset with Circuit Playground Express and

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

Circuit Playground Digital Input

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

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

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

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

Ping Pong Ball Launcher

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

NeoPixel Ring Bangle Bracelet

Paper Airplane Launcher

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

Android GBoard Morse Code Control with Circuit Playground Express

Glowing Smokey Skull. Created by Ruiz Brothers. Last updated on :03:40 PM UTC

Secret Hollow Book Intrusion Detector

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

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

Getting Started with FLORA

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

Adafruit 8x16 LED Matrix FeatherWing

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

14-Segment Alpha-numeric LED FeatherWing

NeoMatrix 8x8 Word Clock

Adafruit Mini TFT with Joystick Featherwing

Crickit Carnival Bumper Bot

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

Adafruit 8x16 LED Matrix FeatherWing

Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

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

IS31FL x9 Charlieplexed PWM LED Driver

Adafruit 7-Segment LED FeatherWings

Crawling Baby Sea Turtle Robot

Introducing Circuit Playground

Coffee Detonator: The TNT Plunger Grinder

Getting Started with FLORA

Circuit Playground Yoyo

Light-Up Angler Fish Embroidery

Adafruit PowerBoost 500 Shield

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

Hammer Time Mini Golf Hazard with Crickit

FLORA and GEMMA ICSP. Created by Becky Stern. Last updated on :30:55 PM EST

TSL2561 Luminosity Sensor

Crickit Powered Holiday Diorama

NeoPixel Basketball Hoop

Getting Started with FLORA

Arduino Lesson 6. Digital Inputs

Lie Ren's Stormflower Gun Blade

Bike Wheel POV Display

Celebration Spectacles

UFO Flying Saucer with Circuit Playground Express

Guardian Shield+ Zelda Breath of the Wild

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Trinket NeoPixel LED Longboard

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

Circuit Playground Express Head-Tilt Ears

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

Monochrome OLED Breakouts

Chirping Plush Owl Toy

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

Reindeer Mask with Animated Eyes

Adafruit Si7021 Temperature + Humidity Sensor

CPX Mystery Dreidel. Created by Kathy Ceceri. Last updated on :51:40 PM UTC

Adafruit TPL5110 Power Timer Breakout

Adafruit Mini TFT " 160x80

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

Adafruit Capacitive Touch Sensor Breakouts

Morning Star POV Double Staffs

Adafruit TPL5111 Reset Enable Timer Breakout

Adafruit AMG8833 8x8 Thermal Camera Sensor

3D Printed Camera LED Ring

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

Introducing Circuit Playground

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

Adafruit HUZZAH32 - ESP32 Feather

MCP Bit DAC Tutorial

Introducing Adafruit Trellis

Adafruit AS channel Visible Light Sensor

NeoPixel LED Cortana Costume

DIY Circuit Playground Shields

Adafruit MPRLS Ported Pressure Sensor Breakout

Adafruit IO Basics: Digital Input

3D Printed LED Goggles

Simple LED Unicorn Horn

Joy Featherwing. Created by Dean Miller. Last updated on :03:07 PM UTC

Crickit Powered Mini Chair Swing Ride!

Adafruit APDS9960 breakout

Transcription:

NeoPixie Dust Bag with Circuit Playground Express Created by John Park Last updated on 2017-12-20 10:00:29 PM UTC

Guide Contents Guide Contents Overview Code It Setup Animation Color Touch Variable Color Simulate It Pseudo ON/OFF Conditional If/Then/Else Build and Use It Touch Sensor Bag in a Bag 2 3 6 7 8 12 14 17 19 20 24 24 25 Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 2 of 30

Overview How can your fairy costume be complete without a glowing pixie dust bag?! It sparkles and blinks, and you can squeeze the touch sensor wire to change the colors on the beautifully twinkling NeoPixel ring! This fun, sophisticatedlooking prop is easy to build with absolutely no soldering required. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 3 of 30

This project updates and simplifies the classic GEMMA-based build by using the Circuit Playground Express -- what used to use multiple pieces of hardware is now built into a single board! Plus, all of the programming is done with the user-friendly graphical interface of MakeCode, so no need to type code or use the Arduino IDE if you don't want to. Besides the Circuit Playground Express, you also need: 3 AAA battery pack with on/off switch, or 3.7V Lithium Ion battery with charger for a more compact build short wire alligator clip test leads translucent pixie dust bag small plastic bag flake salt, such as Morten's Kosher salt, used to as light diffusing "pixie dust" Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 4 of 30

Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 5 of 30

Code It Your NeoPixie dust bag must twinkle beautifully -- what better way to do that than set the LEDs to a solid color and then randomly sparkle some of them white? You'll also want to be able to change the colors by tapping the capacitive touch sensor. You can program all of these effects without typing a line of code, simply by dragging and dropping elemental code blocks, you can create Circuit Playground Express software in no time, and even test it out with the virtual Circuit Playground Express simulator built into the page. Be sure you've gone through the tutorial here on the basics of MakeCode for Circuit Playground Express to make sure you know the basics of creating and uploading your code. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 6 of 30

Setup You'll begin with a nice clean canvas -- nothing but a single, empty forever loop block. This is where all of the repeating command blocks will live, running over and over and over again. Let's also add an on start block to set one parameter from the beginning -- this is a good place for any commands that need to run once each time the Circuit Playground Express is turned on or reset. Think of it as a sort of initialization block. From the Light category, add a set brightness block to the on start block and set the value to something moderately bright, say 80. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 7 of 30

Animation Next, you'll light up the NeoPixel ring using photon blocks. Photon blocks act like a sort of pen that can move to any position on the NeoPixel ring (0-9) and light or color a NeoPixel when it is "down". It doesn't change the color of any NeoPixels when it is "up", just like a pen that is lifted off the paper. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 8 of 30

From the Light category, grab a photon pen up block and place it into the forever loop. Then, change the dropdown to pen down. You'll want to light up and color your NeoPixels by moving the photon pen around while the pen is down, so add a photon forward by 1 block to the forever loop. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 9 of 30

To create the organic, irregular sparkle pattern, you'll have the photon pen move a random number of positions (between 0-4), by adding a pick random 0 to 4 block to the photon forward by block. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 10 of 30

You'll do the same sort of trick to vary the brightness, using the set brightness block and another pick random block, with the value range set from 0 to 40 To slow things down just a touch, add in a slight pause with the pause (ms) block. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 11 of 30

Here's what the animation now looks like -- go ahead and test it out! Color Touch By default the LEDs will light up red. Red is nice, but how about some other colors, too, when the mood strikes? You'll now add touch input that allows one of the capacitive touch pads of the Circuit Playground Express to switch the color Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 12 of 30

values every time you tap it. From the Input category, add an on buttona click block. Change the input to one of the pin pads, in this case pin A5. (Any of the seven pin A pads will work as capacitive touch pads.) Change the input mode to down instead of click. This means the input condition is met the moment you touch the pad, not when you touch and release. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 13 of 30

Add a set all pixels to red block from the light category to the on pin A5 down block. To make the ring flash white when the pad is touched, change the dropdown from red to white. Variable Color To change the color of the photon in the forever block, we'll use a variable. This variable, called "pixiecolor", will store a value that changes each time you touch the capacitive pad, and the value will be used by the photon set color block. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 14 of 30

In the Variables category, click the Make a Variable button, then type the name pixiecolor and click Ok. Drage the change item by 1 block into the on pin A5 down block, then change the dropdown to your pixiecolor variable. So that the color change is more dramatic, set the change value to 50. Add a photon set pen hue block to the forever loop, just under the photon pen down block. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 15 of 30

Instead of the default 0 value, drag an instance of the pixiecolor variable block on to the photon set pen hue. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 16 of 30

Simulate It Test out the color change now by clicking the gold pad on the Circuit Playground Express simulator at pad A5. You'll see the color change each time you click it. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 17 of 30

Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 18 of 30

Pseudo ON/OFF You may not always want your NeoPixie Dust Bag to sparkle, but it isn't convenient to unplug the battery all the time, so let's use the on-board slide switch to turn off the LEDs. Grab an on switch moved left block from the Input category, then duplicate it and set the second one's dropdown to right. Like you did before, create a new variable, this time naming it "ON/OFF". Drag a set item to 0 block into each switch block, and then change their variable dropdown choices to ON/OFF. The Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 19 of 30

left position will be ON, so set the value to 1, leaving the right position to 0. Conditional If/Then/Else So you now have a variable named ON/OFF that changes depending on the slide switch position. But how do you actually use that to control the lights? The answer is with a conditional if then else block. This block does two things: it tests if a certain condition is met, and then it executes the proper set of blocks depending on that answer. In our case: if the variable ON/OFF is equal to 1, then play our animation blocks, else, set all the pixels to black. From the Logic category, get an if then else block and place it in the forever loop. Then place all of the animation blocks inside the then section. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 20 of 30

To test our condition, we'll need to get a 0 = 0 block from the Logic category and place that at the end of the if statement. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 21 of 30

Place an ON/OFF variable into the first slot, and change the second slot to 1. This means now that when the slide switch is to the left, the variable will be equal to 1 and the animation will play. Now, put a set all pixels to block inside the else section, and change the dropdown to black. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 22 of 30

You finished programming your NeoPixie Dust Bag! Upload it to the Circuit Playground Express and then we'll move on to dressing it up with a battery, bag, and capacitive switch. Here's what the finished code will look like -- feel free to try it out in the simulator (flip the slide switch, then click the A5 pad) and then download it to your Circuit Playground Express and give it a whirl! Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 23 of 30

Build and Use It Touch Sensor To make it easier to change colors when the Circuit Playground Express is in the bag, extend the Pin A5 sensor with a loop of wire. You can simply clip the alligator lead to the pad on both ends as seen here. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 24 of 30

Plug in your battery, make sure the slide switch is set to the left, and then squeeze the wire while holding the board in order to trip the sensor and change colors. Bag in a Bag You'll use the salt to diffuse the light and make the bag look like it's full of pixie dust. To keep the salt off of the electronics, place them inside the plastic bag, then place all of that into the pixie dust bag. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 25 of 30

Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 26 of 30

Now, fill the pixie dust bag with salt. Instant pixie dust! You can hold the bag's wire loop and then squeeze the pixie dust to change the color! Your capacitance is measured by the on-board sensor, and it works best when you have a hand near the board and the other squeezing the wire. Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 27 of 30

Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 28 of 30

Adafruit Industries https://learn.adafruit.com/neopixiedustbag_cpx Page 29 of 30

Now go off and spread magic -- maybe you can even teach someone to fly! Adafruit Industries Last Updated: 2017-12-20 10:00:28 PM UTC Page 30 of 30