Circuit Playground Express Head-Tilt Ears

Similar documents
DIY Circuit Playground Shields

Android GBoard Morse Code Control with Circuit Playground Express

Ping Pong Ball Launcher

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

Slider Crank Mechanism -- from Cardboard and Craft Sticks

Crawling Animatronic Hand

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

Infinity Mirror Valentine's Candy Box

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

Adabot Operation Game

Crickit Carnival Bumper Bot

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

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

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

Bunny Ears with MakeCode

Reindeer Mask with Animated Eyes

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

Paper Airplane Launcher

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

Con Badge with Circuit Playground Express

Wind Blowing Emoji Prop

TRON Bag. Created by Becky Stern

Hammer Time Mini Golf Hazard with Crickit

Adafruit Pi Cobbler Kit

The Scream: Interactive Screaming Painting

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

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

Crawling Baby Sea Turtle Robot

Simple LED Unicorn Horn

Data Logging with Feather and CircuitPython

Circuit Playground Combadge

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

3D Printed Camera LED Ring

Portable Apple Watch Charger

Circuit Playground Yoyo

Mini Golf Course with Circuit Playground and Crickit

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

BLE Light Switch with Feather nrf52840 and Crickit

Crickit Powered Holiday Diorama

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

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

Circuit Playground Express Laser Tag

7 Portable Multitouch Raspberry Pi Tablet

Fiddy - the FTDI Clip

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

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

Adafruit MMA8451 Accelerometer Breakout

UFO Flying Saucer with Circuit Playground Express

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

Trellis 3D Printed Enclosure

Fiddy - the FTDI Clip

Lady Ada's Bento Box. Created by lady ada. Last updated on :55:35 AM UTC

Trinket NeoPixel LED Longboard

Celebration Spectacles

NeoPixie Dust Bag with Circuit Playground Express

3D Printed LED Buckle

Circuit Playground Kaleidoscope

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

Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

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

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

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

Crickit Powered Mini Chair Swing Ride!

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

Adafruit Capacitive Touch Sensor Breakouts

Guardian Shield+ Zelda Breath of the Wild

Circuit Playground Digital Input

3D Printed LED Knuckle Jewelry

MCP Bit DAC Tutorial

DIY Wireless DDR Dance Pad with Bluefruit EZ-Key

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

Punk LED Collar. Created by Becky Stern. Last updated on :02:45 PM EST

Phone-Activated Talking Dog Collar

Adafruit APDS9960 breakout

3D Printed Case for Adafruit Feather

Adafruit PowerBoost 500 Shield

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

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

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

Easy Sparkle Pocket T-Shirt

Adafruit Prototyping Pi Plate. Created by Ladyada

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

Modifying Servos for Continuous Rotation

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Adafruit MMA8451 Accelerometer Breakout

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

Unicorn Hat with Moving Ears

Making Adabot: Part 1

3D Printed Glow-Spike Bracelet

3D Printed 20w Amplifier Box

NeoPixel Ring Bangle Bracelet

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

Bluetooth Controlled NeoPixel Headphones

Adafruit Si7021 Temperature + Humidity Sensor

Prophet 600 GliGli mod

Adafruit 8x16 LED Matrix FeatherWing

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

7" Portable HDMI Monitor

Adafruit 7-Segment LED FeatherWings

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

Transcription:

Circuit Playground Express Head-Tilt Ears Created by Dave Astels Last updated on 2018-10-09 04:07:03 PM UTC

Guide Contents Guide Contents Overview Parts Circuit Playground Express Micro servo Lithium Ion Polymer Battery - 3.7v 1200mAh Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces Plastic Pop Rivets for Cardboard Crafts (20-pack) Supplies Hardware Wiring Construction Designing the ears Aside: Reinforced corner joints Connecting the servos Covering the mechanism Final assembly Code First Some Theory The Code 2 3 3 3 4 4 4 4 5 6 6 8 8 9 13 15 17 18 18 19 Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 2 of 20

Overview This project is a reuse of the project built in the Circuit Playground Express Perk-up Ears (https://adafru.it/cr2) guide. It's a good example of how you can find new and interesting ways to reuse or extend an cool bit of hardware. So if you built the perk-up ears headband from that guide, charge up the battery, and plug in the USB cable. Otherwise, work thought that guide (https://adafru.it/cr2) to build the servo-ears headband. Parts This project uses a Circuit Playground Express, 2 servos, and a LiPo battery. Any size battery can be used, but the 1200 mah model is a good balance between size and lifespan. Your browser does not support the video tag. Circuit Playground Express $24.95 IN STOCK ADD TO CART Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 3 of 20

Micro servo $5.95 IN STOCK ADD TO CART Lithium Ion Polymer Battery - 3.7v 1200mAh $9.95 IN STOCK ADD TO CART Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces $3.95 IN STOCK ADD TO CART Plastic Pop Rivets for Cardboard Crafts (20-pack) $4.50 IN STOCK ADD TO CART Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 4 of 20

Supplies Headband Construction paper Corrugated cardboard Hot glue and glue gun 2 rubber bands of an appropriate size Felt, faux fur, or fabric as desired to cover the ears Jumper wire with male pins if you want to solder to the CPX for a more robust connection flexible/stranded wire to use as an actuator 4 pieces of stiff wire (long male header pins work well) and wire to mechanically connect the servo Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 5 of 20

Hardware Wiring The diagram below shows alligator clip wires being used to connect the servos, and this is fine for prototyping. But if you want things to be more robust some solder is probably going to be involved. You can cut male jumpers just long enough to reach the required pads on the Circuit Playground Express, coming together at the servo plug and solder them in place. For something even more permanent, you can trim the servo cables and solder them directly onto the Circuit Playground Express. Wiring-wise the hardware for this guide is identical to the sound activated ears (https://adafru.it/cr2). The only difference is that you need to orient the Circuit Playground Express correctly. Make sure it's lined up with the battery connector facing directly backward. This will align the X axis of the accelerometer with side-to-side head tilting. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 6 of 20

This might mean you have to adjust where the battery is attached to the headband, so that the cable reaches the battery connector with enough slack to connect and disconnect it as needed. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 7 of 20

Construction Designing the ears The first step is to make some ears from cardboard. You can experiment with shapes using construction paper. It's thin enough to be easy to work with, and still stiff enough to keep it's shape when folded. Once you have a design you like, it can be a template for markign the design on the corrugated cardboard. In this case the square edges are 4cm long. The tip of the ear is 1 cm (3/8") wide, with 1.5 cm (5/8") on either side.. The construction paper prototype can be used as a template to mark out the design on cardboard. Mark them out with the corrugations running from the tip down the length of the piece with the two wings to the sides. The dotted lines are cut part way though, leaving the bottom outside layer. These are the fold lines. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 8 of 20

Aside: Reinforced corner joints Folding the ear results in the bottom and sides meeting along the edges of the cuts. That means there's nothing to glue to. Although hotglue provides some structure Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 9 of 20

itself, it's nice to have a bit more support for the joint. You can do this by cutting a matchstick shaped piece of cardboard to glue inside the corner. That lets each surface (the bottom and side in this case) be glued to this support. All three concave corners can benefit from a bead of hot glue to enhance the bond as well as provide additional structural support. Allow each bead to cool before adding the next or the heat may cause the entire joint to come apart. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 10 of 20

The first step is to fold and glue the ears. You can use the method outlined above. Glue a small piece of plastic straw to the middle of the base of the flap to be a guide for the actuating wire. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 11 of 20

Next glue a servo to the back of each ear as shown: as far down and to the left as possible while still not protruding past the bottom or side of the ear. Consider peeling the foil label from the side of the servo being glued to the ear so that it won't later come off on its own. Poke a small hole near the end of the flap and place a rivet in it. Put the plate on the rivet, but only to the first position. You'll tighten it later. Make a similar hole near the middle of the back of the base. Place a rubber band around the flap rivet as shown. Use a rubber band that is taunt when the flap is extended and has enough strength to pull the flap back when it is released. Poke the other end of the rubber band through the hole in the base so that 2 mm (1/8") sticks through, then push the rivet through it from the top. Place the plate on the rivet and push it on to the second notch. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 12 of 20

Connecting the servos Connect the servos to a board and set them to 0 degrees. Put a "half" horn (see the photos to the left) onto the shaft so that it faces up. Next you need to link the horn to the ear flap. You can use a short piece of wire looped around the rivet at the end of the flap and through the straw guide. The ends can be soldered to a small hook made from a pin from a male header strip bent around the tip of needle-nosed pliers. To connect the hook to the servo horn, make a loop from another, longer header pin and place it through the outermost hole in the horn. Squeeze the loop closed. Hook the hook on the wire through the loop on the horn and squeeze it closed. That will keep it from slipping out when the servo horn point up (and allowing the connecting wire to go slack). Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 13 of 20

The goal is that when the servo is set to 90 degrees the flap is pulled vertical. When the servo goes back to zero degrees, the rubber band pulls the flap back down into the relaxed position. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 14 of 20

Covering the mechanism Now you have working ears. Let's make them look a bit better. You can use any sort of fabric to cover them, felt on the inside and fur on the back would be awesome, but here we just use some felt to keep it easy to see what's going on. Start by cutting an outside piece for each ear. The exact shape isn't overly important; it has to be big enough to accommodate the servo and the motion of the flap, but not so big as to completely obscure the overall ear shape. Secure the corners as shown to the flap rivet, and the front corners of the base. Cut a similar piece for the inside of the ear. It only has to allow for the flap movement. Tack the corners to the same points as the outside fabric, only on the inside of the ear. Then apply glue along the inside edges of the outside piece, and secure the edges of the inside piece. The final two photos show the result. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 15 of 20

Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 16 of 20

Final assembly All that's left is to mount the two ears, the Circuit Playground Express, and the battery to a headband. Hot glue works well with the ears, while double sided tape will work for the board and battery. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 17 of 20

Code We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries, there is a full getting started guide here (https://adafru.it/cpy-welcome). Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. You can learn about Mu and its installation in this tutorial (https://adafru.it/ano). First Some Theory The way we can tell when the acceleometer (i.e. the Circuit Playground Express) is tilted with respect to an axis (X in our case) is to track the value for that axis. 2 Gravity at the Earth's surface is nominally about 9.8 m/s. So when the Circuit Playground Express is level, the value of Z will be ~9.8 and X will be 0. This is show in the lefthand half of the figure below. When the Circuit Playground express is tilted 45 degrees, the force toward the center of the earth will still be 9.8, but it will be divided now between the X and Z axis, as show to the right below they will each be ~6.9 (9.8 * sin(45) ). Tilt it the other way and X will have a negative value. By monitoring the value of X we can therefore tell how far along that axis the Circuit Playground Express is tilted. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 18 of 20

The Code While the hardware for this project is the same, the code is completely different and much simpler than the sound activated ears. After setting up the interfaces to the accelerometer and servos, the loop continually monitors the X component of the accelerometer data (ignoring Y and Z). 1 G is ~9.8 m/s 2 so a comparison value of 5.0 m/s 2 is reasonable. That's a bit less than a 45 degree tilt, as shown above. One thing to notice is that while X of over 5.0 (or below -5.0) will cause the top ear to perk up, it doesn't go back down until the absolute value of X is below 4.0. The range between 4.0 and 5.0 has no effect on the ear. This is generally called hysteresis and is used here to avoid jitter. If the ear went up when X was over 5.0 and down when it was below, it would jitter when the head tilt put X close to 5.0 since you can't hold your head that still, so X would be going back and forth over 5.0. This behavior is typically undesirable, hence the use of hysteresis. The ears go down well below the point at which they go up. The result is nice clean movement. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-head-tilt-ears Page 19 of 20

""" Circuit Playground Express head-tilt activated ears. Adafruit invests time and resources providing this open source code. Please support Adafruit and open source hardware by purchasing products from Adafruit! Written by Dave Astels for Adafruit Industries Copyright (c) 2018 Adafruit Industries Licensed under the MIT license. All text above must be included in any redistribution. """ import time import busio import board import adafruit_lis3dh import simpleio # Setup accelerometer i2c = busio.i2c(board.accelerometer_scl, board.accelerometer_sda) sensor = adafruit_lis3dh.lis3dh_i2c(i2c, address=0x19) # Setup servos left_ear = simpleio.servo(board.a1) right_ear = simpleio.servo(board.a2) #initialize things left_ear.angle = 0 right_ear.angle = 0 while True: x, _, _ = sensor.acceleration if x < -5.0: left_ear.angle = 90 elif x > 5.0: right_ear.angle = 90 elif abs(x) < 4.0: left_ear.angle = 0 right_ear.angle = 0 time.sleep(0.1) Adafruit Industries Last Updated: 2018-10-09 04:07:02 PM UTC Page 20 of 20