3d printed animatronic robot head - adafruit · pdf file3d printed animatronic robot head...

62
3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Upload: duongdan

Post on 05-Feb-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

3D Printed Animatronic Robot HeadCreated by Rick Winscot

Last updated on 2015-10-13 11:50:09 PM EDT

Page 2: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

2357

121622293743505658

Guide Contents

Guide ContentsOverviewTools / MaterialsDesignAssembly: U-JointAssembly: MountsAssembly: Servo PlateAssembly: Rod EndsAssembly: ArmatureAssembly: MouthAssembly: EyesMission ControlSource Code

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 2 of 62

Page 3: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

OverviewHave you ever wanted to build a robot, but don't know where to start? Or... are you looking for aproject that you can cut-your-teeth on?

This servo-controlled animatronic robot head uses two servos for movement, two speakers for eyesand an LED mouth for a friendly remote-controlled robot.

This an advanced project, for people who already know how to control servos and LEDs. Thistutorial will focus on the 3D printing and assembly of the 'bot head!

Robots, animatronics, and puppets - oh my!

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 3 of 62

Page 4: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 4 of 62

Page 5: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Tools / MaterialsYou can get by with fewer tools than I've listed; if you have em' great... if not, no big.

Tools

220 grit sand paperscrew driverhot-glue gunhand torchsoldering ironvariable speed drillhand saw (for cutting the dowel)

Some of the parts might have tight tolerances... I plan on using a M3 tap (http://adafru.it/cTS) toreduce the risk of splitting the plastic.

Alternatively, you could use the tip of your soldering iron to widen holes a bit.

Materials

cute desktop speakers for the eyes3D printed parts2X analog feedback servo

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 5 of 62

Page 6: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

electret microphone5X 3mm LEDS3X 330ohm Resistors4X 8mm M3 screws10X 10mm M3 screws2X M3 nuts5X short wood screws1X 20mm X 120mm dowel (usually sold in meter lengths)super glue5-minute epoxy

Grab your speakers and let's go!

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 6 of 62

Page 7: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

DesignRobot ideas often come to me as I peruse the Adafruit store... this time it was pair of desktopspeakers that got me thinking about WALL-E (http://adafru.it/cTT) and ShortCircuit (http://adafru.it/cTU). The speakers reminded me of their eyes.

I thought to myself, "I wonder what earlier versions of WALL-E and Johnny 5 were like."

A few sketches later, I had a rough-cut on the head ready to go. It's a simple design, a U-joint andtwo armatures connected to two servos.

The red blocky-thing represents an Adafruit feedback servo - an incredibly useful component!

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 7 of 62

Page 8: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

U-joints (http://adafru.it/cTV) provide a huge amount of gestural freedom.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 8 of 62

Page 9: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Limits in articulation are primarily a function of the armature... this is where feedback from theservos can come in useful; you'll be able to sense when a servo starts to bind.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 9 of 62

Page 10: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

It's a simple stack... all the 3D printed parts, with the exception of the base, can fit in the palm ofyour hand.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 10 of 62

Page 11: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

When you're ready, grab the 3D models and print-them-up in a color that suits your fancy; I chooseblack PLA to match the color of the speakers.

3D Models (.stl files)

http://adafru.it/cTW

Print rod ends with a slow / fine setting for an optimal ball and socket fit. Everything else canbe printed coarse and fast.�

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 11 of 62

Page 12: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: U-JointLike I said before, a tap isn't necessary... but it really does help prevent cracking in printed parts.

We want the screws to fit nice and snug in the tiny hub.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 12 of 62

Page 13: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

And fairly loose in the arms that cradle the hub.

Turn the hub as you go to make sure that it moves free and smooth.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 13 of 62

Page 14: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

If it binds too much, you're going to make the servos work much harder than they need to.

We need to add mounting caps for the dowel and the eye plate... so don't assemble the other sideof the u-joint just yet.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 14 of 62

Page 15: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 15 of 62

Page 16: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: MountsYou'll need 2X 8mm M3 screws here...

Tapping these holes isn't necessary, but you can if you like.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 16 of 62

Page 17: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Just make sure that the screw is flush on both sides so that it doesn't get in the way of the u-joint asit pivots or the dowel as it sits flat in the socket.

More 2X 8mm M3 screws...

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 17 of 62

Page 18: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Secure the other side of the u-joint to the eye plate.

Make sure the screws are flush... you'll want the eyes (speakers) to sit flat on the base.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 18 of 62

Page 19: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Now, go ahead and finish assembling the u-joint.

Wiggle the joint a bit as you add the screws to make sure that the joint doesn't bind this directioneither.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 19 of 62

Page 20: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Cut a dowel about 120mm long and mix-up some 5-minute epoxy. Glue the dowel into the mountconnected to the eye-plate... and let it stand for at least 20-30 minutes.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 20 of 62

Page 21: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 21 of 62

Page 22: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: Servo PlateTime to put the servo-plate together with 2X 8mm M3 screws.

Tap the holes if you prefer... or not. Just take it slow so that you don't crack the plastic.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 22 of 62

Page 23: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

ABS is a little more forgiving than PLA when you use the force.

The screws should be flush on the servo side so the servos sit nice and flat.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 23 of 62

Page 24: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

We'll use a short wood screw to hold the dowel in place.

You'll have to make holes in the plate for the screws that hold the servo in place.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 24 of 62

Page 25: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

A silver Sharpie works great on black PLA.

In some cases I prefer to 'drill' using a long hot soldering iron tip; it adds a little strength around thehole.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 25 of 62

Page 26: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

You might have to remove some of the mushroomed plastic around the hole so that the servo fitsflat against the posts.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 26 of 62

Page 27: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Test fit the holes with a screw to make sure that you got the width just-right - not to tight and not tooloose.

The two pieces that form the neck should rotate freely.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 27 of 62

Page 28: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 28 of 62

Page 29: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: Rod EndsRod-ends are made from four bits of plastic and a 10mm M3 screw.

The screw goes into the bulb.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 29 of 62

Page 30: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Two of these ball-joints screw into the back of the eye plate and two are bolted onto servo hornextensions.

If the two halves of the ball retainer aren't flat... smack them with a bit of sandpaper on a flat

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 30 of 62

Page 31: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

surface.

Insert a ball into one half of the retainer...

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 31 of 62

Page 32: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

And make a sammich.

Hold the two retainer halves together with an end-cap. It's a little snug... use the force.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 32 of 62

Page 33: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

We'll make this permanent with plastic rivets. Start by heating one end of a bit of filament until itstarts to slump a bit.

Mushroom the end of the filament out on a flat surface and let it cool.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 33 of 62

Page 34: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Cut the rivet to length and insert it (two of them) into the rod-end.

Heat-up the other end of the rivet.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 34 of 62

Page 35: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

...and your flat surface might not work here to finish the rivet. You can use a pencil eraser to shapethe other end of the rivet or live dangerously and pat the plastic with the tip of your finger.

Molten plastic can stick to your skin... and when it does, it will burn. Seriously.�

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 35 of 62

Page 36: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Repeat these steps to make a set of four... two per armature.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 36 of 62

Page 37: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: ArmatureTime for some hot-glue.

Squeeze in a bit into the rod-end.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 37 of 62

Page 38: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Push the rod in all the way...

Add a little more hot-glue around the base / rod to make it extra secure.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 38 of 62

Page 39: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

A couple things here.

rods should be roughly the same length (+/- 2mm)rod-ends should be aligned

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 39 of 62

Page 40: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Time to attach one end of the armature to a servo; start by cutting off one end of a servo horn.

Hot-glue the servo horn to the servo horn extension.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 40 of 62

Page 41: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Screw the armature on...

And add an M3 nut to hold everything together.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 41 of 62

Page 42: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 42 of 62

Page 43: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: MouthTime for some blink! With 5X 3mm LEDs.

Put a little dob of hot-glue in the hole.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 43 of 62

Page 44: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Quickly press the LED in before the glue cools.

5X awesome.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 44 of 62

Page 45: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Bend the negative leads over each other until you get to the end - clipping the excess as you go.

I stripped the insulation off hook-up wire to cover the leads. Shrink tube can also be used, you'll justhave to make sure that you don't get the area too hot - it might re-melt the hot-glue.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 45 of 62

Page 46: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Organize the leads so that LED one and five, and two and three are connected.

Trim three 330ohm resistors.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 46 of 62

Page 47: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Solder them all in place.

At this point I did add some clear shrink tube to help with strain relief. You could also coat the areain hot-glue as well.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 47 of 62

Page 48: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Just a touch of hot-glue to stick the two pieces of the mouth together.

I've used blue LEDs... the Adafruit store has red (http://adafru.it/777), blue (http://adafru.it/780),

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 48 of 62

Page 49: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

green (http://adafru.it/779), or white (http://adafru.it/778).

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 49 of 62

Page 50: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Assembly: EyesAdd the two armatures, but don't screw them into place yet - you may need to make adjustments.

Screw the other end of the armature into the eye plate.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 50 of 62

Page 51: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

You'll have to guesstimate where to place the speakers. Look all around the perimeter so that youknow where adhesive should go.

Mix-up some more 5-minute epoxy and put a good-sized helping on the plate.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 51 of 62

Page 52: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Put the entire rig on a table and adjust the eye-plate so that it's flat and parallel to the tabletop.Then, place your speakers into the adhesive.

5-minute epoxy is pretty good... but I'd wait more like 30 minutes just to be safe.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 52 of 62

Page 53: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Add the mouth with a bit of hot-glue.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 53 of 62

Page 54: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

If the bare wood dowel bothers you... a black Sharpie can fix that in a jiffy.

Voila!

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 54 of 62

Page 55: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 55 of 62

Page 56: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Mission ControlYou can breathe life into your animatronic creation with a servo controller and a little bit of Arduinocode (http://adafru.it/cTX)... here are two awesome options.

Adafruit 16-Channel 12-bit PWM/Servo Shield (http://adafru.it/1411)Adafruit 16-Channel 12-bit PWM/Servo Driver (http://adafru.it/815)

If programmatic servo control is a little too rigid, you can always give an RC transmitter with a 4-channel receiver a try.

This approach means you will be driving the servos dynamically.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 56 of 62

Page 57: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 57 of 62

Page 58: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Source CodeLet's control the mouth animation dynamically with a little Arduino and an electretmicrophone (http://adafru.it/1063).

I prefer to adjust the gain on the microphone... although you could do it in code.

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 58 of 62

Page 59: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Here's how I hooked up the mouth LEDs to the Arduino.

yellow wire to pin 9: drives the LEDs on the far right and leftblue wire to pin 10: drives the LEDs between the center and outsidepurple wire to pin 11: drives the LED in the center of the mouthgreen wire to ground

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 59 of 62

Page 60: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

And this is the sketch that drives the LEDs based on the sound levels captured by the microphone.

There are some settings in there like HI_CUT, LO_CUT, and DC_OFFSET that you might have toadjust depending on what kind of audio you intend to drive the microphone with and how you'vehooked it up.

As-is, this sketch works pretty well with the mic attached to your shirt just below the mouth.

// Connect LED positive to pins 9, 10, 11 with common ground.

#define MIC_PIN A0 // connected to the out pin on the mic #define DC_OFFSET 3.3 // mic is plugged into 3.3v

const byte HI_CUT = 255; // upper brightness limitconst byte LO_CUT = 40; // lower iimit turns LEDs off

// sample window width in mS (50 mS = 20Hz)const int sampleWindow = 50;unsigned int sample;

int LED_CENTER = 11; // LED at center of the mouthint LED_MIDDLE = 10; // LEDs between the center and outsideint LED_OUTSDE = 9; // LEDs on the outside of the mouth

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 60 of 62

Page 61: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

Have fun with your new robotic friend!

void setup() { // Serial.begin(9600); // remove comment for debugging

pinMode( LED_CENTER, OUTPUT ); pinMode( LED_MIDDLE, OUTPUT ); pinMode( LED_OUTSDE, OUTPUT ); }

void loop() { unsigned long startMillis= millis(); // start of sample window unsigned int peakToPeak = 0; // peak-to-peak level unsigned int signalMax = 0; unsigned int signalMin = 1024; double lvl = 0;

// collect data for 50 mS within a reasonable range while (millis() - startMillis < sampleWindow) { sample = analogRead(MIC_PIN);

if (sample < 1024) { if (sample > signalMax) { signalMax = sample; } else if (sample < signalMin) { signalMin = sample; } } }

lvl = signalMax - signalMin; // max - min = peak-peak amplitude lvl = ( lvl * DC_OFFSET ); // reduce operational range lvl = ( lvl < LO_CUT ? 0 : lvl ); // low cut filter for noise lvl = ( lvl > HI_CUT ? HI_CUT : lvl ); // high cut filter for clipping

analogWrite( LED_CENTER, lvl ); // 100% brightness analogWrite( LED_MIDDLE, lvl * .8 ); // 80% brightness of center analogWrite( LED_OUTSDE, lvl * .3 ); // 30% brightness of center

// Serial.println(lvl); // remove comment for debugging}

© Adafruit Industries https://learn.adafruit.com/3d-printed-animatronic-robot-head Page 61 of 62

Page 62: 3D Printed Animatronic Robot Head - Adafruit · PDF file3D Printed Animatronic Robot Head Created by Rick Winscot Last updated on 2015-10-13 11:50:09 PM EDT

© Adafruit Industries Last Updated: 2015-10-13 11:50:10 PM EDT Page 62 of 62