Simple Animatronics

Since the last Guardian Robot project, we've gotten a number of requests to add a servo and LED to the head – In this project, we'll show you how to do that!

Mounted to the eye is a 10mm blue LED. The head itself is attached to a servo horn and mounted to a micro servo. The head can freely rotate while the eye blink randomly. Surrounding the body are 5mm blue LEDs that illuminate the various surface details.

The random motion of the servo and eye blinks give the illusion of the robot "searching". It's appears quite organic and live like, adding much more dimension to this replica.

Dual Extrusion

The head and body are dual extruded in two different colored filaments. This allows the details to be illuminate by using a translucent filament. The opaque material diffuses the LEDs nicely, giving a soft glow. The details are distinctly separate but merged into the rest of the body via the dual extrusion 3D printing process.

I worked with Steve to redesign the head and body parts. They're optimized for dual extrusion 3D printing but there's also a single extrusion version available. The internal structures are optimized to print with minimal material and still require no supports. The joints articulate freely and are printed in place.

Prerequisite Guides

If your new to electronics and working with LEDs, I suggest you walk through the following guides to get basics of wiring and soldering. The following guides will walk you through setting up Arduino IDE and Adafruit libraries.

Parts & Components

A nice handful of parts and components used to build this project. Always a good idea to have more on hand in case something is damaged or burns out!

1 x 5V Adafruit Trinket
micro-controller
1 x Blue 3mm LEDs
Pack of 25
1 x Red 3mm LEDs
Pack of 25
1 x Blue 10mm LEDs
Pack of 25
1 x Resistors
220ohm 1/4watt pack of 25
1 x Slide Switch
breadboard friendly
1 x JST male connector
JST-PH 2-Pin SMT Right Angle Connector
1 x 500mAh battery
Lithium Ion Polymer Battery - 3.7v 500mAh

Cool Tools!

These things really do help make building the project smoothly. You don't need them all of them, but I recommend them.

1 x Wire Strippers
Hakko Professsional Quality 20-30 AWG Wire Strippers - CSP-30-1
1 x Wire Cutters
Flush diagonal cutters - CHP170
1 x Soldering Iron
Adjustable 30W 110V soldering iron - XY-258 110V
1 x Panavise
Panavise Jr. - PV-201
1 x Helping Third Hands
Helping Third Hand Magnifier W/Magnifying Glass Tool - MZ101
1 x 30AWG Wire
Silicone Cover Stranded-Core Wire - 30AWG in Various Colors
1 x Solder Wire
Solder Spool - 1/4 lb SAC305 RoHS lead-free / 0.031" rosin-core - 0.25 lb / 100 g

Circuit Diagram

Use the diagram above to reference the wired connections. The length of wires are not exact, this is just a visual representation of the circuit. A small piece of the Adafruit Perma-Proto is used to break out additional voltage and ground pins. On the back of the Trinket is a male JST connector – A JST slide switch adapter is connected to turn the circuit on and off. The circuit is powered by a 3.7V 500mAh lipo battery.

Wired Connections

Below is a list of the wired connections in this circuit. Most of the voltage and ground connections will be wired to the piece of Adafruit Perma-Proto breadboard PCB.

  • VCC from 3mm LEDs to voltage on Adafruit Perma-Proto
  • GND from 3mm LEDs to ground on Adafruit Perma-Proto
  • GND from 10mm LED to ground on Adafruit Perma-Proto
  • VCC from 10mm LED to pin #0 on Adafruit Trinket
  • VCC from micro servo to voltage on Adafruit Perma-Proto
  • GND from micro servo to ground on Adafruit Perma-Proto 
  • Data from micro servo to pin #4 on Adafruit Trinket

Strand of 3mm LEDs

A strand of 6x 3mm LEDs are arranged and wired to a single voltage and ground pin on the Perma-Proto PCB. The LEDs are wired together in series. The diagram below shows how they can be wired, but it's not a 100% representation of the strand. In this project, the leads are much shorter and the LEDs are spaced further apart.

Getting Code Onto Trinket

Before we start disassembling or building the circuit, it's a good idea to get code uploaded to the micro-controller first. If you don't write / understand code, don't to worry! You don't need to be a programmer to be able to upload prewritten code :-) 

We'll walk you through the whole process. 

First, visit the Trinket tutorial page by clicking the button below. Follow the instructions to download & setup the Arduino IDE and install drivers.

Make sure you are able to get sketches compiled and uploaded, especially the blink example in the tutorial. Once you are comfortable with using the Trinket, you can continue!

Install Adafruit TiCoServo Library

Next, we need to add support for the micro servo. The Adafruit TiCoServo library is used to manage servo pulses. You'll need to install the library either manually or using the Library Manager in the Arduino IDE.

Search for TiCoServo to locate it and Install!

You'll need to install the Adafruit package to the additional boards manager in order to install the Adafruit TiCoServo library. Visit the Adafruit Arduino IDE setup tutorial to install the profile!

Uploading Code to Board

Now that we have the Adafruit boards & NeoPixel library installed, we can get our code ready to upload onto the board. Select all of the code listed below in the black box and copy it to your clip board. Then, in Arduino IDE, paste it in the sketch window (making sure to overwrite anything currently there). Next, goto the Tools menu > Board and select Adafruit Trinket (if you're using the 3V Adafruit Trinket version use Trinket 8Mhz. If you're using the 5V Trinket, select Trinket 16Mhz). Now you can click on the "check mark" icon to verify the code. If it's all good, we can continue to upload the code to the board.

Connect USB Data Cable to Trinket

Be sure to use a micro USB cable that can transfer data - A USB cable that ONLY charges devices will simply not work. Plug it into the microUSB port on the Adafruit Trinket board and the USB port on your computer (try to avoid connecting to a USB hub). As soon as you plug it in, you'll see a red LED blink on the Adaruit Trinket - This let's you know the board is ready to accept code. While the LED is blinking, click on the Upload button (It's a right arrow icon, next to the check mark). The Arduino IDE will notify you if the upload is successful and completed.

We've had issues with uploading code to the Trinket on a Mac with El Capitan – If you're running this setup be sure to use a USB 2.0 Hub. The issue is due to USB 3.0 ports on Mac hardware.
// SPDX-FileCopyrightText: 2018 Limor Fried for Adafruit Industries
//
// SPDX-License-Identifier: MIT

// Trinket Servo Monster sketch
// Hardware: Adafruit Trinket (3V or 5V), micro servo, LED + resistor
// Libraries: uses Adafruit_TiCoServo library to manage servo pulses,
// even though NeoPixels are NOT being used here.

#if !defined(__AVR_ATtiny85__)
 #error "This code is for ATtiny boards"
#endif
#include <Adafruit_TiCoServo.h>
#include <avr/power.h>

// Servo parameters.  Pin MUST be 1 or 4 on a Trinket.  Servo position
// is specified in raw timer/counter ticks (1 tick = 0.128 milliseconds).
// Servo pulse timing is typically 1-2 ms, but can vary slightly among
// servos, so you may need to tweak these limits to match your reality.
#define SERVO_PIN  4 // Pins 1 or 4 are supported on Trinket
#define SERVO_MIN  4 // ~1 ms pulse
#define SERVO_MAX 26 // ~2 ms pulse

#define LED_PIN    0 // "Eye" LED is connected here

Adafruit_TiCoServo servo;

void setup(void) {
#if (F_CPU == 16000000L)
  // 16 MHz Trinket requires setting prescale for correct timing.
  // This MUST be done BEFORE servo.attach()!
  clock_prescale_set(clock_div_1);
#endif
  servo.attach(SERVO_PIN);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
}

uint32_t lastLookTime = 0; // Time of last head-turn

void loop(void) {

  unsigned long t = millis(); // Current time

  // If more than 1/2 second has passed since last head turn...
  if((t - lastLookTime) > 500) {
    if(random(10) == 0) { // There's a 1-in-10 chance...
      // ...of randomly moving the head in a new direction:
      servo.write(random(SERVO_MIN, SERVO_MAX));
      lastLookTime = t;   // Save the head-turn time for future reference
    }
  }

  // Unrelated to head-turn check,
  if(random(10) == 0) { // there's a 1-in-10 chance...
    // ...of an "eye blink":
    digitalWrite(LED_PIN, LOW);  // The LED turns OFF
    delay(random(50, 250));      // for just a short random moment
    digitalWrite(LED_PIN, HIGH); // then back ON
  }

  delay(100); // Repeat loop() about 10 times/second
}

Dual Extrusion

The head and body are 3D printed with a dual extrusion setup. The swirling detail patterns are 3D printed in a translucent material to allow the glow of LEDs to shine through. The main body and head are 3D printed in a silver colored filament. 

We used an Ultimaker 3 and Sigma BCN3D 3D printers to produce the parts. They both achieve dual extrusion differently, but render similar results.

Other machines can be used, such as the flashforge creator pro, Prusa i3 MK2 with Multi Material upgrade kit or the Palette+ from Mosaic Manufacturing

Single Extrusion

If you don't have access to a 3D printer with a dual extrusion tool head but still want to make this project, you can print the "single extrusion" version of the models. You can 3D print the parts in a translucent filament and then paint the parts to achieve a similar effect.

CURA & Simplify 3D

We used CURA 2.6 to slice the parts for the Ultimaker 3. Simplify 3D was used for slicing for the Sigma BCN3D.  Both use different slice settings and will have their own specific profiles.

Other machines will need to have their slice settings adjusted in order to produce the parts.

Post Processing

The parts can be sanded and painted for a more polished surface. I like how the surface looks a bit bumpy from the layers. In the video game, the guardian robots are ancient, so they look pretty rusty and weathered. If the parts are dual extruded, they may need some additional clean up. Some of the surfaces may have excess material. They can be clipped off using flush diagonal cutters

Dry Fitting Head & Body Parts

It's a good idea to test the parts by fitting them together. The head attaches to the body and twisted to lock in place. You should be able to free rotate the head when it's attached to the body.

3D Models

The guardian robot was designed by Steve, you can find his work on thingiverse.  Based on his original design, the Hackable version features parts for designed for electronics. Download the STLs using the links and 3D print them.

Remixed Parts

I redesigned the bottom cover part to fit the micro servo, battery and slide switch.  This can be downloaded from the remix section on the Thingiverse page or the link below. 

Head & Eyes

First up is the LEDs for the eye that are mounted to the head of the robot. There's 2x LEDs (10mm and 3mm) that are wired together. The 10mm LED is mounted to the eye socket while the smaller 3mm LED is soldered behind the 10mm LED. The smaller 3mm LED illuminates the details in the head. A 220ohm resistor is used to limit the current and avoid burn out.

Prep 10mm LED

The two legs of the 10mm LED were bent to form a right angle using a pair of flat precision pliers. This will make it easier to mount to the eye socket on the robots head. Tin the legs with a bit of solder, near the upper area close to the LED bulb.

Prep 3mm LED

Now we'll need to prep the smaller 3mm LED. Trim the two legs short, but keep the anode (voltage) leg slightly shorter than the cathode (ground) leg. The longer leg on the 3mm LED is the anode (positive voltage). I used a pair of flush diagonal cutters to trim the legs short. Tin the shortened legs with a bit of solder.

Prep Resistor for LED

We'll use a 220ohm resistor to limit the current from the battery to prevent the LEDs from drawing too much current and burning out. Trim the two legs short and tin them with a bit of solder. 

Wires for LED

We'll need two wires to connect to voltage and ground. I used 30AWG silicone cover stranded core wire for this. This wire has nice insulation and it's thin, flexible and yet durable. The two wires were about ~10cm in length. Make sure to strip the tips and tin them with solder. Tinning the tips of the wires will make it easier to connect them to the LEDs.

Connect 3mm to 10mm LED

The 3mm LED rests on top of the 10mm LED with the corresponding legs mating. Double check to ensure the correct legs are matching. Cathode to ground and voltage to anode. Add a bit of solder to the tip of the soldering iron and apply it to the mating legs for a secure connection.

Connect Resistor

Next, we need to attach a 220ohm resistor to the cathode (ground) leg of the 10mm LED. First, trim the two legs short but keep the anode (positive) leg slightly longer – this helps differentiate the two connections from each other. Hold the resistor over the cathode and apply heat to attach them together. Apply a small mount of solder to the tip of the soldering iron and add it to the connection.

Attach Wires to LEDs

Now it's time to solder the two wires to the LEDs. Attach one wire to the resistor that is soldered to the cathode of the LED. Then, attach the second wire to the anode of the LED.

Test LEDs

With the wiring completed, we can then test out our LED circuit using a coin cell battery or equivalent. The resistor will limit the current from the battery and flow through both the 3mm and 10mm LED. 

Mount LED to Head

Now it's time to attach the LED circuit to the head. Start by inserting the 10mm LED through the bottom of the head. Position the bulb behind the eye socket and firmly press inward until it's secured in place. If the LED doesn't fit inside the socket, you can use a filing tool to smooth out the edges and loosen up the tolerances. Test the LED circuit using a coin cell to ensure it wasn't damaged during the installation process.

Do not use a Continuous Rotation Micro Servo (FS90R) for this project! The library and code does not currently support that type of servo.

Install Servo Horn

The micro servo comes with a variety of servo horns and mounting screws. Use the wide version and install it onto the teflon bushing. Install and fasten the shorter screw to secure the horn to the bushing.

Attach Servo to Head

Now we need to mount the servo horn to the bottom of the  robots head. First, it's a good idea to tap the mounting holes on the bottom of the 3d printed part. Place the servo horn over two of the mounting holes and see where the holes can line up. Insert and fasten the machine screws into the tabs to secure the horn to the head.

Test Rotation

With the servo horn attached to the head, it's a good idea to test out the rotation by twisting the head back and forth. Ensure the wires from the LEDs are not tangling up with the servo horn or body. 

Perma-Proto PCB and Trinket

Next up, we'll work on wiring the components to the Adafruit Trinket. To make wiring a little bit more manageable, we'll use a piece of Perma-Proto PCB to expand the voltage battery and ground pins on the Trinket.

Slice of Perma-Proto PCB 

We only need a small piece of the Perma-Proto PCB – The ground and power rails are ideal. To cut the F4 PCB material, you will need to use a rotatory tool with a thin cutoff wheel. When cutting F4 substrate, it's very important to be in a well ventilated area and wear a proper breathing respirator. Alternatively, you can use a strip of flexible perma-proto, which you can cut using a pair of scissors.

Ground and Voltage Wires

In order to connect our PCB to the Adafruit Trinket, we'll need to fashion ourselves two short pieces of wire. Measure, cut, strip and tin two pieces of 30AWG wire. Then, tin a voltage and ground pin on the PCB. Solder in the two wires into each pin, respectively. 

Perma-Proto to Trinket

Connect the voltage wire from the PCB to the BAT pin on the Adafruit Trinket, Connect the ground wire from the PCB to the GND pin on the Adafruit Trinket. I recommend tinning the pins before soldering in the wires.

Secure PCB to Trinket

For better wire management, I found tacking the piece of perma-proto PCB to the back of the Adafruit Trinket. It's a flexible way of securing the two substrates together. It's easy to remove and doesn't leave behind much mess. I used elemer's mounting tack.

Connect the LED Eye

Next up we'll work on connecting the wires from the LED eye to the trinket and perma-proto PCB. The voltage wire goes to pin #0 on the Trinket while the ground wire goes to one of the ground pins on the perma-proto PCB.

 

Eye Ground to Perma-Proto

Connect the ground wire from the LED eye to one of the ground pins on the piece of perma-proto PCB. I suggest adjusting or removing the mounting tack from the PCB before soldering – If the tack gets inside the pins while soldering, it can melt and mix with the solder, so be careful! 

Eye Data to Trinket

Connect the anode wire from the LED eye to pin #0 on the Adafruit Trinket. For better wire management, solder the wire from the back of the Trinket. This keeps the orientation of the wires consistent, making the wires more manageable. 

Eye Blink Test

With our LED eye now wired and connected to the circuit, we can now test it out! The code should be uploaded to the Adafruit Trinket. If you haven't yet, make it so! You can connect a microUSB cable to the Trinket and to a USB port on your computer (or USB battery bank) to power it up.

Trim Servo Cable

The length of the cable on the micro servo is longer than we need, so we can cut it short. It should be able the length of the wire on the LED eye. 

Tin Servo Wires

Peel apart the three wires from the micro servo and strip them using wire strippers. Apply solder to the strands of wire to tin them. Careful not to get the tip of the soldering iron too close to the wire insulation, it can easily melt!

Connect Servo Data Wire

The yellow/orange colored wire from the micro servo needs to be connected to pin #4 on the Adafruit Trinket. I wired it from the back of the Trinket to make wiring more manageable. 

Servo Voltage & Ground

The red colored wire from the micro servo connects to one of the voltage pins on the piece of perma-proto PCB. The brown wire will connect to one the ground pins on the perma-proto PCB.

JST Connector for Adafruit Trinket

In order to easily connect/disconnect a lipo battery to the Trinket, we'll need to attach a female JST connector. On the back of the Adafruit Trinket are solder pads for connecting a JST connector. First, I tinned the positive and ground pads on the  Trinket. Then, I stuck a very small piece of tack to the Trinket (Adafruit logo is a perfect spot!) and mounted the JST connector. With it tacked it place, I just heated up the pads and applied a small amount of solder to each terminal. There's two pads on the sides, these are used for adding mechanical strength to the two parts.

Test JST Connector

Double check your work to ensure the JST connector has solid solder joints. You can plug in a lipo battery to test out the circuit. It should power up and start running the code.

Circuit Test

Once the Trinket is powered on, the LEDs should start randomly blinking. You should also see the servo horn start rotating. The head will rotate back and forth randomly. Set it on the desk and watch it struggle to move around. Next up, we'll work on some final details and assemble this all together!

LEDs & Resistors

To illuminate the details in the body of the guardian robot, I  fashion together a strand of red and blue 3mm LEDs. These are not programmatically controlled, rather are simply ON or OFF – this is mostly just for aesthetics. You don't need to do this portion of the guide if you don't want – albeit is time consuming to create a strand of LEDs. Their are easier ways to achieve a similar effect, perhaps with these pre-made LED strands.

LED Strand

I used 6x 3mm LEDs to make the strand. A mix of reds and blues to give it some color variation. You can add more or less to your strand depending on how bright you want the body details to glow. I found six to cover most of them, this is a hexapod after all ¯\_(ツ)_/¯

Add Resistors to LEDs

I proceeded by prepping the LEDs and resistors by trimming all of the legs short. Then, tinning all of the electrodes with a bit of solder. After that, I soldered a 220ohm resistor to each of the cathodes. 

Wires for LED Strand

We'll need two more longer pieces of wire to connect the LEDs together in series. The LEDs will be spaced apart ~6mm so the strand needs to be roughly 4cm in length. Measure, cut, strip and tin the two wires.

Self Adjusting Wire Stripping

Next, we'll need to create gaps in the wire that run across the two. Essentially stripping insulation in-between wires, creating segments to which we can solder the legs of the LEDs. To do this, I used a self adjusting wire stripper. With it, one can strip multiple pieces of wire at once. This features a set screw for fine tuning the grip for thinner 30AWG wires.

Solder LEDs to Wires

With the LEDs and wires prepped, we're ready to solder them together. You'll want to tin the exposed ares of the wire with a bit of solder. I highly suggest using a pair of helping third hands to hold an LED in place while soldering them to the wires. It's also handy to hold the wires in place with a pair of tweezers as the wire can get hot if left over the iron too long. Notice the orientation of the wires and LEDs. Repeat this process for all of LEDs to complete the strand.

Test LED Strand

Make sure you've checked all of your solder joints to ensure they're solid and not bridging. Once the strand of LEDs was finished, I tested it out using a coin cell battery – Super quick and easy way to test LEDs. Now is a good time to adjust wire lengths and use some heat shrink tubing to keep the wires together.

LED Diffusion

I test fitted the strand of LEDs to see how well they were being diffused. You can get more illumination when they're pointing towards features. The further away the light source, the more soft and diffused the surface appears.

Install LED Strand

With the LED strand now tested and adjusted, it's time to mount it to the inside of the robo body. I used mounting tack to secure each LED to the surface of the body. A moderate glob of tack is suffice to mount an LED in place. It was a bit tricky to fully fit my fingers in the body, so you'll need some finesse. Maybe a pair of tweezers can help with this. 

Adjust LED Strand Wiring

It's difficult to fully see inside the robo body, but you should be able to see where the LEDs are mounted and how the wires are lined up. Take the opportunity to adjust them so they're right up against the surface wall and evenly distributed. You'll want the two wires to stick out from the top of the body.

Connect LED Strand

Now it's time to connect the LED strand to the perma-proto PCB. Solder the voltage wire from the LED strand to the an available voltage pin on the perma-proto PCB. Then, solder the ground wire to a ground pin.

Attach Head To Body

To attach the head to the body, we'll need to install the Trinket, Perma-Proto PCB and wiring through the top part of the robo body. Slowly and carefully fit all of the components through the body – The micro servo at a slight angle. The bottom of the head features tabs that lock to the body. Twist to mate the tab features and press in to fit the head to the body.

JST Slide Switch Adapter

Although we could just connect a lipo battery directly to the Trinket, it would just stay powered on until the battery ran dry. I found it necessary to use a JST slide switch adapter to easily connect/disconnect a lipo battery. This is kinda of a project on it's own. Luckily, I've already created a learning guide on how to fashion one together.

Install Switch

The bottom cover part has a dedicated spot for housing a slide switch. It is installed at an angle and firmly pressed in place. The switch actuator is accessible from the other side. 

Install Battery

Connect the battery to the switch by plugging in JST connectors. The battery can be installed onto the bottom part with mounting tack or double sided tape. I wrapped the cable from the battery around the servo mounting platform. I was able to sandwich the battery in between the platform and switch holder. I also trimmed the cable from the battery short – only do this if you know what your doing.

Connect Switch to Trinket

The JST switch adapter can now be plugged into the Adafruit Trinket. If the circuit powered on, slide the switch to power it off – We need the circuit to be stationary while we install the bottom part to the body. 

Install Bottom

With the battery and switch now connected to the Adafruit Trinket, we can finish this project by closing it up. I carefully embedded the components into the body and adjusted the wiring. Slowly fit the bottom part over the opening and orient it so the cabling from the micro servo is lined up with the notch in the mounting platform. Check to ensure none of the wires are being kinked. Carefully press the bottom part into the body so the micro servo is fitted into the mounting platform. The bottom part has nubs on the sides that lock into the body. Twist until the parts lock together.

Head Rotation Tests

Good idea to test and see if the head can rotate freely before we flip the switch. Slowly rotate the head back and forth. The head should be able to rotate ~180 degrees. If you find the head gets stuck, a wire might be snagged or maybe the there's some access debris in between the head and body. A filing tool should be able to smooth that out.

Power It Up!

Now's let's turn it on and see it come to life! Not sure that's entirely a good idea, but as long as you make robot friend and not enemy, we should be a-ok ;-)

Photos, Ideas, Get Creative!

I had a lot of fun filming the making of this project. I think this could make a really interesting stop-motion animation. The segments in the limbs are pretty adjustable and have a tight tolerance. I was able to rest a fidget spinner over one of the claws and it stayed in place – How cool is that?!

I'd love to see your build, if your make one, please share it with me! You can post a make on the thingiverse page or just tag @adafruit or @ecken on instagram or twitter.

Project Concepts

I think these components and code can be adapted for lots of other projects. It's basically some randomly rotating thing with blinking lights. I can imagine this could be useful for cosplay props, weapons and simple animatronics. The circuit can easily be upgraded to feature USB battery recharging with a Trinket Lipo Backpack breakout.

This guide was first published on Jul 18, 2017. It was last updated on Jul 18, 2017.