Bunny Ears with MakeCode

Similar documents
Easy Sparkle Pocket T-Shirt

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

NeoPixie Dust Bag with Circuit Playground Express

Infinity Mirror Valentine's Candy Box

Ping Pong Ball Launcher

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

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

Slider Crank Mechanism -- from Cardboard and Craft Sticks

LED NeoPixel Corset with Circuit Playground Express and

Crawling Animatronic Hand

Adabot Operation Game

Con Badge with Circuit Playground Express

Circuit Playground Express Laser Tag

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

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

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

Crickit Carnival Bumper Bot

Unicorn Hat with Moving Ears

Wind Blowing Emoji Prop

Sword & Wand Prop Effects with Circuit Playground

Crawling Baby Sea Turtle Robot

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

Portable Apple Watch Charger

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

Crickit Powered Holiday Diorama

NeoPixel Ring Bangle Bracelet

Circuit Playground Express Head-Tilt Ears

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

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

Clockwork Goggles. Created by John Park. Last updated on :03:10 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

Celebration Spectacles

Paper Airplane Launcher

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

Circuit Playground Yoyo

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

Hammer Time Mini Golf Hazard with Crickit

Tent Lantern. Created by Timothy Reese. Last updated on :17:25 AM UTC

Trinket NeoPixel LED Longboard

Light-Up Angler Fish Embroidery

3D Printed Camera LED Ring

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

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

UFO Flying Saucer with Circuit Playground Express

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

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

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

Mini Golf Course with Circuit Playground and Crickit

Mystical LED Halloween Hood

Guardian Shield+ Zelda Breath of the Wild

Simple LED Unicorn Horn

Adafruit PowerBoost 500 Shield

Adafruit Capacitive Touch Sensor Breakouts

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

Reindeer Mask with Animated Eyes

Android GBoard Morse Code Control with Circuit Playground Express

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

GPS Logging Dog Harness

Adafruit TPL5110 Power Timer Breakout

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

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

Crickit Powered Mini Chair Swing Ride!

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

Getting Started with FLORA

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

Stumble-Bot. Created by Dano Wall. Last updated on :04:06 AM UTC

Secret Hollow Book Intrusion Detector

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

Chirping Plush Owl Toy

3D Printed LED Knuckle Jewelry

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

NeoPixel Basketball Hoop

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

NeoMatrix 8x8 Word Clock

Bluetooth Controlled NeoPixel Headphones

DIY Circuit Playground Shields

Getting Started with FLORA

BLE Light Switch with Feather nrf52840 and Crickit

TRON Bag. Created by Becky Stern

Morning Star POV Double Staffs

Learning with LEDs. Created by Rick Winscot. Last updated on :39:11 PM UTC

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

Adafruit TPL5111 Reset Enable Timer Breakout

Data Logging with Feather and CircuitPython

Glowing Neopixel Resin River Table

7 Portable Multitouch Raspberry Pi Tablet

Fiddy - the FTDI Clip

NeoPixel LED Cortana Costume

7" Portable HDMI Monitor

3d Printed Neopixel Tactile Switch Buttons

3D Printed Case for Adafruit Feather

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

3D Printed LED Buckle

LED Lightbox. Created by Sam Clippinger. Last updated on :50:00 AM UTC

Adafruit Pi Cobbler Kit

Lie Ren's Stormflower Gun Blade

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

Bike Wheel POV Display

3D Printed 20w Amplifier Box

Transcription:

Bunny Ears with MakeCode Created by Erin St Blaine Last updated on 2018-08-22 04:05:47 PM UTC

Guide Contents Guide Contents Introduction Tools & Other Materials Programming with MakeCode Set Up the Light Strand Add "Shake" Animation Download Code Add Tilt Animations Shifting Color Hues Wiring Diagram Power Assembly Wire the Neopixels Secure Strip Ends Install in the Ears 2 3 3 5 5 6 7 8 9 11 11 13 13 15 17 Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 2 of 21

Introduction Everyone needs a friend who is all ears. Get egg-cited and make a set of motion-reactive light up bunny ears with Circuit Playground Express and MakeCode. These are the perfect accessory to draw attention away from your bad hare day. Be the fast and the furriest; the most unique bunny in the park. (How do you catch a unique bunny? Unique up on it) Wear them to IHOP or take them on your Bunnymoon, or just use them to cover your receding hare line. You'll be so sparkly that everyone will want to hop down YOUR bunny trail. This project is a great one to do with kids. There's a bit of soldering involved, a bit of hand sewing, and you'll have fun dragging and dropping code snippet blocks with MakeCode, to make the ears react to your bunny hops. Egg-spress yourself with Circuit Playground! 1 x Circuit Playground Express Circuit Playground Express Microcontroller ADD TO CART 1 x Neopixels 60/m White Neopixel Strip ADD TO CART 1 x LiPoly Battery 500mAh LiPoly battery ADD TO CART 1 x Battery Charger USB LiPoly Battery Charger ADD TO CART 1 x On/Off Switch Battery extension cable and on/off switch ADD TO CART 3 x Stranded Wire Red, Black and White stranded wire OUT OF STOCK Tools & Other Materials Bunny ears (https://adafru.it/c9w) Hair clips / barettes Soldering iron & accessories Clear 1/4" heat shrink (https://adafru.it/c9x) Hot glue gun Heat gun Needle & thread Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 3 of 21

Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 4 of 21

Programming with MakeCode The Circuit Playground Express can be programmed a number of ways: it will run Arduino code, CircuitPython, or you can program it with MakeCode. Microsoft MakeCode for Adafruit is a web-based code editor for physical computing. It provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users. This means you can drag and drop light animations and functionality using the Circuit Playground Express' onboard sensors without ever writing a single line of code. Just snap the blocks together and watch your lights dance. https://adafru.it/aep https://adafru.it/aep For this project, I'm using the tilt and shake functions on the Circuit Playground Express to trigger animations. Tilt your head left and a "photon" animation runs from left to right. Tilt your head right and the same animation runs from right to left. If you shake your head (or hop up and down like a bunny) then the twinkle animation is triggered. Check out this guide (https://adafru.it/cjc) for more info on working with neopixel strands and building your own animations. Go to https://makecode.adafruit.com/ (https://adafru.it/wmd)and select "New Project". Set Up the Light Strand We soldered our light strand to pin A1. Tell the code by adding an on start loop (Loops > on start ). This block will run ONCE when the board powers up, so it's the perfect place to define our setup. Drag the on start block onto the workspace. We don't need the "forever" block so you can delete it. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 5 of 21

Next go to "Variables" add a new variable called (strip). Then, drag set (item) to 0 into the on start block. Change the default (item) variable to the one you just made: (strip). Go to the "Neopixel" bin (you may need to click the "Light" bin to make it appear). Drag create strip on (A1) with (24) pixels into the block you just made, replacing the (0). Change the (24) to reflect the number of pixels you have in ONE ear (I have 20). Add "Shake" Animation Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 6 of 21

Go to "input" and grab the on (shake) block. Go back to the "Neopixel" bin and choose (strip) show animation for (500) ms You can choose from six different pre-programmed animations. I chose the Twinkle animation. You can also specify here how long you'd like the animation to run when you shake / hop. I liked 2 seconds -- experiment to find what works for you. To make the lights turn off at the end of the specified time, place a Neopixel > (strip) clear block after the animation block. Download Code Let's test to see if it's working. 1. Plug your Circuit Playground Express into your computer with a USB cable. 2. Click the reset button. 3. Green lights will appear on the Circuit Playground's face and it will appear in your list of devices, called CPLAYBOOT. If you don't see this, try double-clicking the reset button instead of single-clicking. Click the pink Download button on your MakeCode screen and the code you just made will download to your computer. Drag it onto the CPLAYBOOT device. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 7 of 21

Shake your Circuit Playground and see the neopixel strands twinkle! Add Tilt Animations Let's make the lights react when you tilt your head to the side. We'll use the "Photon" option for this. It's a little more complicated to use than the pre-canned animations, but you have a lot more control as well. Photon moves a light or series of lights along the light strand from one end to the other. You can control a lot of factors like color, speed and tail length. More about using the Photon animation in this guide (https://adafru.it/cjj). Drag another instance of on (shake) from the "Inputs" bin. Change (shake) to (tilt left) To start the Photon animation, drag an instance of (strip) photon pen (down) from the "Neopixels" bin. NOTE: there are also instances of the photon functions in the "Light" bin. These don't have a variable attached, which means these animations will run on the face of the Circuit Playground and not on your Neopixel strip. Be sure you've got the right one! From the "Loops" bin, drag a repeat (4) times block inside the on (tilt left) block. Change the (4) to the number of neopixels in ONE strip (I have 20). This will make the photon animation repeat for each neopixel you have, creating the apparent motion. Add Neopixel > (strip) photon forward by (1) block inside the loop block. Drag a pause (500) ms block below it. These blocks will control your animation speed. The first block advances the light by one pixel and the second Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 8 of 21

controls how quickly this happens. I changed mine to pause (10) ms because I want the animation to run really fast. Get another instance of (strip) photon (pen down). The quickest way to do this is to click on the block and copy it to your clipboard, and then paste it into your workspace (ctrl-c, ctrl-v). Change (pen down) to (eraser). From here you can drag it below your loop function within the on (tilt left) block. Copy and paste the loop function too, and drag that below the new (eraser) function you just made. Change (strip) photon forward by (1) to (strip) photon forward by (-1). This will make the animation disappear (eraser) in the reverse direction as it was originally drawn. Shifting Color Hues Each hue on the neopixel strip is assigned a value: red is 0, yellow is around 60, and the colors cycle back around to red at 255. We can use a variable to make the colors change periodically. If we start with red (hue 0) and add 5, we get an orangey-red. Add 5 more, and then 5 more, and the color will cycle through to orange and yellow and so on, all the way around the rainbow. MakeCode is smart enough to automatically wrap back to 0 when it reaches 255. Let's use the (item) variable, which is already set up for us. Drag Neopixel > (strip) photon set pen hue (0) into your loop as shown in the photo. Drag Variables > (item) to replace the (0). Drag Variables > change (item) by (1) below that. Set the (1) to (5). This will change each LED's hue by 5 steps each time a pixel is colored. A value of 5 makes a nice gradient, but play with it to get a value you like. Download the code and drag it to CPLAYBOOT to test your animations. You can download and test as many times as Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 9 of 21

you want until you get it just right. Once (tilt left) is working the way you want, we can copy/paste most of the blocks to add a (tilt right) animation. Click the on (tilt left) block and copy/paste another instance of it onto your worktop. Change on (tilt left) to (tilt right). Change the FIRST instance of (strip) photon forward by (1) to (-1) and the SECOND instance to (1). This will make the animation run from right to left, instead of left to right. Here's the completed project that you can play with directly. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 10 of 21

Wiring Diagram Power Circuit Playground VOUT --> Neopixel 5v (to one strip) Circuit Playground G --> Neopixel G (to the same strip) Circuit Playground A1 --> Neopixel IN (2 wires: one to each strip) Your battery will plug in to one end of the JST extension cable / switch. The leads from the other end of the switch will be soldered to the IN end of your second strip of neopixels (the one NOT used by the Circuit Playground). The two neopixel strips will also have a power and ground wire running from the OUT of one to the OUT of the other. Power will flow from the battery through the switch, and into the second Neopixel strand. It will continue out of that strip and into the first strip, then from there into the Circuit Playground. This will both protect your Circuit Playground from LEDs drawing too much voltage accidentally, and also balance the weight and bulk of the battery and the Circuit Playground between the two bunny ears. Remember: Pixel data can only flow one way, from the IN end of the strip to the OUT end. Power can flow either direction, so it's fine to hook up your power supply to the opposite end of the strip from your microcontroller. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 11 of 21

Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 12 of 21

Assembly Wire the Neopixels Measure the distance around the edges your bunny ears and cut two neopixel strips to fit snugly inside. My strips ended up with 20 neopixels each. Cut carefully through the center of the copper pads, being sure to leave enough pad on each side for soldering. Find the "in" end of each cut strip (the arrows should be facing AWAY from that end). Solder 3 color coded wires to each strip: red to 5v, black to G, and white to IN. The wires should be about 5" long for one strip, and about 10" long for the other. We can trim them down later, so when guesstimating lengths, always err on the side of "too long". We'll call the one with shorter wires strip #1, and the one with longer wires strip #2. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 13 of 21

Look closely at your on/off switch. Figure out which end the battery wants to plug into: this is the male end and we'll leave that one alone. Find the other end (the female end) and snip the connector off with wire cutters. Splice the long red and black wire attached to strip #2 to the red and black wire coming from the switch. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 14 of 21

Solder a 4" red and black wire from the OUT end of strip #1 to the OUT end of strip #2. Test to be sure your connections are good by hooking up some alligator clips to the remaining free wires. Attach BOTH white wires to A1. Then attach the free red wire coming from strip #1 to VOUT and the free black wire to G on the Circuit Playground. If all your connections are good, the strips will light up when you plug in your battery and tilt the Circuit Playground. Let's secure the ends of the strips so they don't ever pull out or break while you're wearing the ears. Secure Strip Ends Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 15 of 21

Cut four pieces of 1/4" clear heat shrink and place them over the end of each strip. Before you shrink them down, squirt some hot glue onto the strand to cover the solder connections. Then while the glue is still wet, use a heat gun to shrink the heat shrink down. This will create an indestructible and waterproof seal for your LED strips. Take off your alligator clips and solder those four wires to the Circuit Playground's pads. Install in the Ears Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 16 of 21

Use a thread ripper to carefully remove both ears from the headband. Fold the neopixel strip gently in half with the lights facing outwards. Slip the strips up inside the ears to be sure they fit. Orient the ears so the animation runs from left to right when you tilt the board to the right, and vice versa. Think about how it's going to sit on your head and be sure it makes sense to you. It's easy to get the ears on backwards, so take a minute and be sure you've got things laid out right. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 17 of 21

Once you're SURE you've got the layout right, remove the neopixel strand from one ear and turn the ear inside out. The Circuit Playground needs to be oriented carefully for the tilt sensors to work right. Mark the top and bottom with respect to the ground and sky while the ears are on. Don't just align it with the ear's top and bottom since the ear will be on your head at an angle. Sew the Circuit Playground onto the back panel of the ear through the unused pads. You can also use your thread ripper to cut a small slit in the back of the ear to make the USB port accessible, in case you want to change or adjust the code later on. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 18 of 21

Turn the ear right-side out again and replace the neopixel strip. Stuff the battery inside the opposite ear. Test your orientation again! The Circuit Playground should be on the BACK of one ear and the USB port should be perpendicular to the ground. Be sure the animation on both ears is running in the correct direction. We'll need to be able to get to the battery for charging. Cut a small hole near the bottom of the batterycontaining ear and slip the JST connector through before plugging it into the switch. This way it will be on the outside, so you can easily hook it up to the charger. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 19 of 21

Place the switch on the back of the headband between the ears. Stuff the wires inside the ears and sew them to the headband, being sure you can still get to the JST connector. Decorate your ears with flowers, ribbons, glitter, jewels, or the crushed skulls of your enemies. The ears are a little heavier now than when you bought them. Use some hair clips or barrettes to help secure them to your head, so they don't tip off when you tilt to activate the animations. Adafruit Industries https://learn.adafruit.com/bunny-ears-with-makecode Page 20 of 21