Arduino animatronics- make your awesome costumes more awesome! using ATmega328 microcontroller

Here’s how to add lights, sound and action to your favorite Halloween project using the open source Arduino microcontroller. Arduino is easy to learn to use and it opens up a whole new world for costume builders and creature creators. If you want to learn how to connect wires, servos, LEDs and use sound effects to add that something special to your latest project then this is for you.
I’ll show you how to make a neat little compact Arduino servo controller board with built in servo connectors that is perfect for costuming and haunted house applications. There are multiple code examples, wiring diagrams and I’ll show you how to connect sensors and even how to connect two controllers using wireless radios.
Here’s a little movie clip of what is easily possible- an animatronic Predator cannon with laser sight, cannon firing sound and head tracking motion control.

Here’s an Iron Man hand repulsor with servo to open the forearm missile compartment. Follow along and find out how to make your awesome costumes more awesome…
Note– While this instructable is written for the beginner, this tutorial assumes you know how to use a soldering iron and other assorted tools like wire strippers and wire cutters. Please be sure to take proper safety precautions, wear safety glasses when using cutting tools and have adequate ventilation when soldering. If you aren’t yet comfortable soldering small surface mount components don’t fret- I’ve posted links in the reference section that will help you become a soldering champ in no time.

Step 1 First you need an Arduino

Arduino? What exactly is Arduino?
Arduino is an open source microcontroller- essentially it is a small computer with an easy to use cross platform programming language. It allows you to create interactive objects based on sensory inputs (physical computing.) You can use it to do something simple like make an LED fade or have a servo move when you push a button or have it do something very complex like control a robot by processing sensor inputs, send the inputs to a computer over a wireless network and then send commands back to the robot. The applications are really limited only by your imagination and there are thousands of examples of cool projects all over the Web. There are several books about Arduino and its capabilities and I’ve listed a few in the reference section.
Which Arduino to use?
There are several variations of the Arduino controller available so which one do you use? It depends on your application. Some have more input pins than others if you need a lot of sensor inputs. For the purposes of this instructable you really can use any Arduino you like as the information presented applies to most every version. Here is a spreadsheet that shows most of the current variations available-
https://spreadsheets.google.com/ccc?key=0AsCUiP6WbJIvcG8xalA3QVdmb3JVT0ptWE9VNC02WEE&hl=en#gid=0
If you are going to use an Arduino Uno or Mega or any Arduino that has built in USB then you can skip to the getting started section.
Building a servo board
Since my focus is mainly on costume building I decided to use the Sparkfun Arduino Pro Mini and then build a compact servo application board for it that has multiple servo outputs, analog inputs and digital outputs. I also added a socket for an Adafruit Xbee wireless radio adapter as well as a charging circuit for a single cell LiPo battery to power the controller.
The reasons I really like the Pro Mini are its very small form factor, low cost and low power requirements. It operates on 3.3V, which means it can be powered by a single LiPo cell and that makes it easy when connecting sensors that run on 3.3V.
The latest version servo board has eight servo outputs, four digital outputs and six analog inputs. The servo outputs are also digital outputs- they’re just configured to make it really easy to connect hobby servos. The earlier version seen in the photos has six servo outputs. Each servo output has three pins- ground, power and signal. The analog inputs are configured the same way- each input has three pins- ground, power and signal. This configuration makes it super easy to connect individual sensors. The board measures 1.75″ x 2.30″ so it’s pretty small.
The board has a circuit for charging the LiPo cell that powers the controller. There is a mini USB port for 5v input power. Simply connect the battery and then plug in a USB cable and the battery will automatically charge. There is a charging indicator- the LED is on when the battery is charging and then it will automatically turn off when the battery is fully charged.
The mini USB port will also power the controller, even without a battery connected. The mini USB port is only used as a power source connector while charging or during times when a LiPo battery is not available- there is no data transmission using the mini USB port and you are limited by the amount of power a USB port can provide.
Code is uploaded to the controller using a USB to serial adapter (more on this later.) This adapter can also power the controller over USB without the need to connect the battery. This comes in really handy when you’re testing code and you want to power the controller without having to connect the LiPo battery.
I’m providing all the necessary EAGLE files so people can modify the design to suit their own needs.

Step 2 Building the controller

Building the controller
Tools and materials
Soldering iron- A good quality soldering iron is a must. I received an Aoyue 2900 soldering station a couple years ago for Christmas and it’s been great. You won’t believe the difference once you start using a good soldering iron.
http://sra-solder.com/product.php/6363/22

I also use a small tip for soldering small surface mount components-
http://sra-solder.com/product.php/6397/0
Wire cutters/wire strippers- Small flush cutters are the best. If you don’t have wire strippers or cutters then these will work well-
http://www.adafruit.com/index.php?main_page=product_info&cPath=8&products_id=152
http://www.adafruit.com/index.php?main_page=product_info&cPath=8&products_id=147
Tweezers- Get some small tweezers to work with surface mount components. Here’s an inexpensive set-http://sra-solder.com/product.php/6409/79
Magnifiers- Being able to see what you’re working on makes a world of difference.
http://www.adafruit.com/index.php?main_page=product_info&cPath=8&products_id=291
Multimeter- Most any multimeter will work. You don’t need to spend big $$$. I personally own a Wavetek Meterman 16XL and it’s great. If you don’t already own a multimeter and are really getting into hobby electronics then this meter will probably do everything you could ever want-
http://www.adafruit.com/index.php?main_page=product_info&cPath=8&products_id=308

Servo board PCB-
http://batchpcb.com/index.php/Products/47581
Arduino Pro Mini- http://www.sparkfun.com/products/9220
USB mini-B connector- http://www.sparkfun.com/products/587
capacitors- 2 ea 1210 package 1uF SMD ceramic capacitors
http://us.element-14.com/kemet/c1210x105k5ractu/capacitor-ceramic-1uf-50v-x7r-1210/dp/94M5711
resistor- 1ea 1206 package 1K Ohm SMD resistor
http://us.element-14.com/welwyn/wcr1206-1k0fi/resistor-thick-film-1kohm-250mw/dp/98K2656
LED- 1 ea 1206 package SMD LED
http://us.element-14.com/vcc-visual-communications-company/vaol-s12rp4/led-2×1-5mm-red-133mcd-624nm/dp/27R0088
JST connector- 1 ea
http://www.sparkfun.com/products/8612
MAX1555 IC- 1 ea
http://www.sparkfun.com/products/674
http://us.element-14.com/maxim-integrated-products/max1555ezk-t/ic-battery-charger-li-ion-340ma/dp/59J2761?Ntt=MAX1555
Straight break away header pins – 2ea 40 pin row
These come in really handy so it’s always good to get extras to have on hand
http://www.sparkfun.com/products/116
Female break away header pins- 2 ea 40 hole row
These also are super handy to have around
http://www.sparkfun.com/products/115
Single cell LiPo battery- 1ea (you can use any capacity you like.)
http://www.sparkfun.com/products/339
USB mini-B cable- 1 ea
Odds are you’ve already got one but if you don’t here you go-
http://www.sparkfun.com/products/598
Assembling the servo board
The first thing to do is build the charging circuit. I usually start with the smallest components first. I’ve found the easiest way to solder SMD parts is to get a tiny bit of solder on your soldering tip and touch it to one of the component pads on the PCB. Then hold the component in place using tweezers and heat up the pad and component pin- this allows you to get the part attached to the board so you can check its alignment for the rest of the pads. Then simply solder each of the remaining pads. There is a great series of SMD soldering tutorials here- http://www.sparkfun.com/tutorials/36
Begin by soldering on the MAX1555 IC (labeled U1) -this can only go on one way. Next comes the LED– make sure to check the polarity as it is labeled on the PCB (the LED cathode is connected to one end of R1.) Then solder resistor R1 followed by the capacitors C1 and C2. These can be soldered on either direction. Next comes the mini USB connector- this one is a bit tricky as the pins are positioned nearly underneath the connector. Now solder on the JST connector. Make sure to double check your soldering job for these connectors as they receive a fair bit of mechanical stress.
Now test your charging circuit. Plug in a USB cable and check the voltage at the JST battery connector. It should read about 4.2-4.3V. Now connect the LiPo battery. If everything is OK the small LED should turn on, indicating the battery is charging. Disconnect the battery.
Now solder on the pins to connect the Pro Mini board. This is done by soldering on the break away straight header pins. First insert the long pin ends into the PCB, flip the board over and solder them in place. Double check your solder joints. Now flip the board over and place the Pro Mini board in place on top of the exposed pins and solder all the pins in place. Next solder the remaining straight pins into place in the digital out positions and the 3.3v port along the bottom of the board.
To finish the board solder all the female headers in place. The best way I’ve found to cut the female headers is to remove a pin where you want to make a cut- just yank the pin out the bottom using a pair of pliers. Then take wire cutters and cut through the opening left by the pin. Now take a file (or sandpaper) and smooth out the cut edge.
Make sure your board is getting power by plugging a USB cable into the mini USB port on the controller board. The red LED on the Arduino Pro Mini should light up.
That’s it- your controller is ready to go!

Step 3 Getting started

Getting startedTo upload code to your Arduino servo board you need a USB to serial adapter. I use the Sparkfun FTDI Basic 3.3V breakout. You can also use the Adafruit FTDI friend (make sure to set it to 3.3V.) Either adapter will work great (you do have to solder a connector to the bottom of the Sparkfun adapter- you can use either straight or 90 degree pins.)
I really like these boards because you can see the LEDs light up when they are transmitting. You also need to make sure you have the latest FTDI drivers on your computer (you can get the most current drivers on the product web pages.)
Sparkfun FTDI Basic 3.3V breakout
http://www.sparkfun.com/products/10009
Adafruit FTDI friend
http://www.adafruit.com/index.php?main_page=product_info&cPath=18&products_id=284
You simply plug the FTDI Basic breakout into the programming socket on the controller board and connect it to a computer using a USB mini-B cable. Make sure to line up the GRN and BLK indicators.
If you’re using an Arduino with built in USB then you don’t need a USB to serial adapter- it’s built into the Arduino board. Just connect it to a computer using a USB cable and you’re good to go.
Programming environment
Now you need to download the Arduino software which is located here:http://arduino.cc/en/Main/Software
At the time of this writing I am using Arduino 0018. If you want to use the newer Arduino Uno or Mega2560 then you should use the latest release (0021 at this time) as the Uno and Mega2560 use a different type of USB to serial connection that is not supported by previous versions.
I also highly recommend reading the Arduino environment guide here:http://arduino.cc/en/Guide/Environment
The code you will use has several parts:
1. Program description/comments-
This is where you say what the program does
2. Variable declaration section-
This is where you assign input/output pins, etc.
3. Setup section-
This is where you set pins as inputs or outputs, etc.
4. Loop section-
This is the program that will run based on the conditions of your variables and setup sections.
When your program runs it will first define your variables, then execute the setup section once and will then execute the loop section over and over.
So what you do is open the Arduino software, add (or write) your code (called a sketch), verify (compile) your code, connect your Arduino to your computer, select the USB/serial connection, select the type of Arduino you’re using then upload your code to the Arduino.
Here’s the process-
1. Open Arduino window and add/write code-
Just open the Arduino program and paste the code example you want to use into the window (or write your own code.)
2. Verify-
Hit the verify button to compile your code. It will inform you if there are any errors with your code.
3. Connect board-
Connect the servo board to your computer using the USB to serial adapter- if you are using an Arduino with built in USB then just plug the Arduino directly into your computer.
4. Select connection-
This tells the USB to serial adapter which serial port you are going to use. The one to select is labeled beginning /dev/tty.usbserial so from the top menu go to Tools>Serial Port>/dev/tty.usbserial-(insert port name here)
5. Select board-
This tells the Arduino program which version board you are using. From the top menu go to Tools>Board>Arduino Pro or Pro Mini (3.3V, 8Mhz) w/ ATmega328 if you are using the Pro Mini servo board or choose the correct model Arduino.
6. Upload code-
Hit the upload button to send the code to your Arduino.
That’s it!

Step 4 Making connections- motors, LEDs and transistors

Inputs and outputs
Now we need to connect a few devices like servos, sensors and LEDs to our controller. The controller has inputs and outputs. Things like sensors and switches are input devices, while servos, LEDs and motors are output devices. The inputs and outputs are both analog and digital- a digital input is like a switch, so it’s either on or off. Analog inputs are variable- it’s more like a dimmer switch that gives you a range of values.
Digital outputs are similar- if the controller output pin is set HIGH then it’s on. If it’s set LOW, then it’s off. This is great if you want to turn on a motor or LED. If you want to change the brightness of an LED or make a servo motor move then you want to make the controller output pin an analog output. This is done using PWM (pulsewidth modulation.) PWM simply allows the controller to fake an analog voltage output by setting the output pin HIGH and then setting the output pin LOW within a few microseconds or milliseconds of each other. If you pulse the pin HIGH for the same length of time you pulse it LOW you would get an average voltage of half the total voltage so the output pin would give you 1.6V instead of 3.3V. The amount of time the pin stays HIGH is called pulsewidth. The ratio of time for the pin to go from LOW to HIGH to LOW is called duty cycle. If you shorten the amount of time the pin stays HIGH relative to the amount of time it stays LOW you will effectively lower the output pin voltage. It really sounds more complicated than it is but this will come in really handy later on when you want make LEDs dim or make a servo move. Fortunately most of this complex stuff is done for you in the Arduino code libraries but it’s still really good to know.
Sensors
There are all kinds of sensors- bend sensors, force sensitive resistors, accelerometers, potentiometers, joysticks, etc.
These analog sensors change their output voltage according to how you use them. In the examples we’ll use button switches to turn things on and off and we’ll use joysticks (potentiometers), bend sensors and accelerometers to make servos move.
When designing an animatronic system for costuming I try to match the type of sensor used with a specific body motion. Think about how the person wearing the costume is going to use it. Bend sensors are great if you want to make a LED dim or servo move by bending your finger. For even more control I can place a small joystick on a fingertip and use that to make a servo move. For a head tracking system that makes servos follow your head movement I use an accelerometer (from a Wii nunchuck) and I use fingertip switches to trigger sound effects. You’ll see how these work in the examples.
Sparkfun has a good size momentary push button switch that is breadboard friendly-
http://www.sparkfun.com/products/9190
Here’s the smaller version-
http://www.sparkfun.com/products/97
All of the sensors we’ll use are connected to the Arduino input pins. A potentiometer is a device commonly used in an application like a stereo volume knob- it’s a type of variable resistor. If you supply the potentiometer with 3.3V when you turn the knob the output voltage will range from 0 to 3.3V. A joystick is simply two potentiometers in a common housing- one for the X axis and one for the Y axis.
Sparkfun has a 10K potentiometer-
http://www.sparkfun.com/products/9939
They also have a couple of small joysticks-
http://www.sparkfun.com/products/9032
http://www.sparkfun.com/products/9426
A bend sensor is a resistor that changes its resistance value according to how much you bend it. By adding another resistor and creating a voltage divider, we can change the output voltage of the bend sensor to match the degree of bend. The only real drawback to bend sensors is that they don’t have the wide range that a potentiometer has.
Sparkfun sells a bend sensor here-
http://www.sparkfun.com/products/8606
Accelerometers work by sensing a change in acceleration and then they alter their output relative to the change in acceleration. When you tilt an accelerometer it measures acceleration due to gravity- the more you tilt it the greater the change in output. Accelerometers are commonly used in video game controllers and cell phones.
A Wii nunchuck has a 3 axis accelerometer, joystick and two pushbuttons for $20.
Motors
Servos
Hobby servos are small geared motors that have a circuit board and potentiometer to control their rotation. This allows them to be able to move to an exact position relative to your input sensor signal. Most servos can move nearly 180 degrees and some can even do multiple rotations as well as continuous rotation. Servos have three wires- ground, power and signal. The signal wire (usually yellow or white) is connected to the Arduino output pin. The power and ground wires are connected to a separate power source, usually ranging anywhere from 4.8V to 6V. The reason for connecting servos to their own power supply is that motors generate a fair bit of electrical noise, which can cause glitches or a stuttering effect in their movement.
If you have an input sensor that generates an input voltage from 0-3.3V the Arduino takes that analog voltage and assigns it a value from 0-1023 using an analog to digital converter (ADC.) The code on the Arduino then tells the servo how far to move based upon the converted value. So if your sensor outputs 1.65V then you would get a reading of 511 and your servo would move half of its rotation. Many Arduino boards operate on 5V so the same sensor at the same position would read 2.5V and the servo would still rotate half way. A continuous rotation servo would rotate in one direction, stop as the sensor gave a 1.65V reading and then reverse direction as you caused to sensor to raise the input voltage.
Controlling a servo is done by PWM. You send a send a pulse to the servo on the servo signal line every 20 milliseconds. The pulsewidth tells the servo what position to move to. Most servos operate within a 1 to 2 millisecond pulse range so a 1 millisecond pulse tells the servo to move to the 0 degree position and a 2 millisecond pulse tells the servo to move to the 180 degree position. Any pulse between 1 and 2 milliseconds tells the servo to move to a position that is proportionate between 0 and 180 degrees.
I get all my servos here-
http://www.servocity.com
DC motors
Unlike most servo motors DC motors are best used when you need continuous rotation, especially when you want high RPM. Since DC motors can draw a fair amount of power they are connected to the Arduino output pin using a transistor or a PWM speed controller.
Pololu sells a large variety of small DC motors-
http://www.pololu.com/catalog/category/22
Stepper motors
I don’t usually use stepper motors in my animatronic projects (at least not yet!) but I felt they are worth mentioning. Stepper motors allow for precise positioning as well as continuous rotation and speed control. The drawback to them is that they require a fair bit of electrical power and they’re usually significantly larger and heavier than a servo of equal torque rating. Small stepper motors can be salvaged from old printers and scanners. Unlike DC motors stepper motors have multiple individual coils inside that must be activated in a proper sequence in order to get the motor to move. The Arduino controller is able to drive stepper motors using a specific driver chip or transistor array that is capable of energizing each individual coil in the motor. For more information about steppers have a look in the reference section.
LEDs
Small LEDs are pretty simple to connect to the Arduino- just remember to use a resistor between the Arduino output pin and the resistor cathode to limit the current flow. You can put a resistor on either the anode or cathode of the LED- either way will work. Most of the small 3.3v LEDs will have a forward current of around 20mA so a resistor value around 100 Ohms works pretty well. For accurate resistor value calculations have a look here-
http://led.linear1.org/1led.wiz
For my Iron Man repulsor I made a small 2″ diameter LED board that has 24 PLCC-2 LEDs. You can get the bare PCB here-
http://www.batchpcb.com/index.php/Products/41872
The board uses 24 1206 package SMD 100 Ohm resistors-
http://us.element-14.com/vishay-dale/crcw1206100rjnea/resistor-thick-film-100ohm-250mw/dp/59M6948
I frequently buy PLCC-2 super bright LEDs on eBay at good prices-
http://stores.ebay.com/bestshop2008hk
High power Luxeon LEDs have a much higher current rating and will work best using some type of constant current source to drive them (there are several instructables on this.) A 1 Watt Luxeon LED will have a forward current of 350mA so you cannot connect it directly to an Arduino output pin. Much like a DC motor you will need to connect it to the output pin using a transistor.
Sparkfun sells Luxeon LEDs and a constant current driver-
http://www.sparkfun.com/search/results?term=Luxeon&what=products
http://www.sparkfun.com/products/9642
Transistors
A transistor is basically just an electronic switch. Each Arduino output pin is limited to 40mA output current so we’ll use a particular type of transistor known as an NPN Darlington transistor to turn on high current devices. These transistors have three pins- the collector, emitter and base. The base pin is connected to the Arduino output pin using a 1K Ohm resistor. The collector pin is attached to the high power device and the emitter pin is connected to ground. When the Arduino output pin is set HIGH the transistor turns on and allows electricity to complete a circuit.
For applications that do not have power requirements over 1 Amp I designed a small transistor board that connects to digital out pins 10-13 using ribbon cable and two eight pin IDC connectors. This uses four SOT-23 package SMD transistors and four 1206 package 1k Ohm SMD resistors. The board is really easy to solder.
Transistor board PCB-
http://batchpcb.com/index.php/Products/41936
SOT-23 NPN Darlington transistors 4 ea-
http://us.element-14.com/fairchild-semiconductor/mmbt6427/bipolar-transistor-npn-40v/dp/58K1891
1206 SMD 1K Ohm resistors 4 ea-
http://us.element-14.com/yageo/rc1206jr-071kl/resistor-thick-film-1kohm-250mw/dp/68R0298
2×4 pin IDC connector 2ea-
http://www.surplusgizmos.com/8-Pin-2×4-IDC-Ribbon-Cable-COnnector_p_1879.html
For loads up to 5A I use a TIP 120 transistor in the TO-220 package. These are great for small DC motors and servos. Use a 1K Ohm resistor to connect the transistor base pin to the Arduino output pin.
I usually buy TIP 120 transistors from my local Radio Shack. They’re very easy to get online as well.
Power supply
To power the Arduino servo board and servos you need two separate power sources- one single cell LiPo battery for the controller and a small 4.8V- 6V battery pack (4AA batteries work just fine) to power servos. The servo board has an additional socket that provides power from the LiPo cell to power low voltage devices like LEDs.

Step 5 Now let’s have some fun!

Example 1- LEDs
This is really simple- we’re going to make two LEDs blink and another LED fade. The code will run over and over as soon as you apply power.
It’s really easy to set up circuits like this using a breadboard. With each example I’ll show how to wire everything up using either the servo board or an Arduino.
Copy and paste this sketch into your Arduino window-
/*
* Example 1
* LED Control
* This example will blink two LEDs and then fade another LED
* Honus 2010
* Fading code created 1 Nov 2008 by David A. Mellis, modified 17 June 2009 by Tom Igoe
*/
int ledPin1 = 13;  // control pin for LED
int ledPin2 = 12;
int ledPin3 = 11;
void setup() {
pinMode(ledPin1, OUTPUT);  // sets the LED pin as output
pinMode(ledPin2, OUTPUT);
digitalWrite(ledPin1, LOW);  // sets the LED pin LOW (turns it off)
digitalWrite(ledPin2, LOW);
}
void loop()
{
digitalWrite(ledPin1, HIGH);   // sets the LED pin HIGH (turns it on)
delay(500);                    // waits 500 milliseconds
digitalWrite(ledPin2, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);    // sets the LED pin LOW (turns it off)
delay(500);
digitalWrite(ledPin2, LOW);
delay(500);
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin3, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(40);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin3, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(40);
}
delay (2000); // wait two seconds
}
For more Detail: Arduino animatronics- make your awesome costumes more awesome! using ATmega328 microcontroller


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top