Archives for posts tagged ‘arduino’

mustache-themed Hi-Striker


So Crushtoberfest is approaching again, and the party plans are in full swing. In case you missed it, Crushtoberfest ’08 was the house party that capped off a six week mustache growing contest among BDC employees and their friends and families. Last year’s feat-of-strength competition featuring the Captains of Crush grippers was a huge success, so we decided to step it up this year.

We liked the idea of a Hi-Striker, the classic carnival game where you swing an oversized hammer and try to ring the bell. But renting a Hi-Striker is not cheap, and we saw the opportunity to build something awesome. So going with the vague carnival theme (and the overt mustache theme) I generated this concept sketch for an electronic Hi-Striker, featuring a larger-than-life Tom Selleck head with light up eyes and fireballs shooting from his ears.

Here’s the plan: The contestant will strike the rubber pad with the hammer, compressing the sealed rubber hose under it. An air pressure sensor attached to one end of the hose will generate an analog voltage (up to 5v), the Arduino Mega will read the voltage and light up the LEDs according to a predefined scale. If the hit is a “ringer” then the LEDs will light all the way to the top, Tom Selleck’s eyes will light up, and fireballs will shoot from his ears. BTW the fireball effect is a flash paper/model rocket ignitor thing we worked out for last year’s party but never used. We also plan to have sound effects go with the LEDs, using the Adafruit Wave Shield for Arduino.

Stay tuned for more.

LED wiring

The Arduino Mega has 54 digital I/O pins, 50 of which are each driving an LED on the Hi-Striker. Each pin can drive up to 40mA, so the only additional components needed are one 100k current-limiting resistor per LED.

For testing, a simple cascading loop runs through the (first 16) LEDs one at a time:

const int ledCount = 16;    // the number of LEDs in the bar graph
int ledPins[] = { 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 };   // an array of pin numbers to which LEDs are attached

void setup() {
  // loop over the pin array and set them all to output:
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    pinMode(ledPins[thisLed], OUTPUT);

void loop() {
  // loop over the LED array:
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    digitalWrite(ledPins[thisLed], HIGH);  // turn on the LED
    delay(20);                             // wait
    digitalWrite(ledPins[thisLed], LOW);   // turn off the LED

LEDs & gravity

I thought it would be a nice touch if the LEDs in the Selleck Striker behaved more like the metal ringer in an old school mechanical hi-striker. So rather than rising up the scale in a linear way, what if it looked like the LED “ringer” was being pulled down by gravity (and friction, and air resistance) like the real thing?

time_distanceSo I figured an ascending object will decelerate in the same way a falling object will accelerate, since they’re both subjected to the same force (gravity). I found some formulas for acceleration due to gravity, particularly :


where d = distance, g = the gravitational constant, and t = time. I would calculate the trip from top to bottom as if the ringer was falling, then use that data in reverse.

The LEDs turn on in sequence, with a delay value in between to determine how long each one stays on (and how fast the “ringer” appears to move). So in order to determine that value I need to solve for t in the equation above. So:


I know that on Earth the gravitational constant — or g — is 9.8 m/s² (meters per second per second). I know the distance d between each LED is 1.37″, or .035m. So the time tx to get from the very top LED to the next one is:


So the first .035m step down from the top will take 59ms. In order to find tz for the second step, I need to find ty for the total distance from the top to the second step (.035m x 2 = .07m), then subtract tx for the first step:




I need to do this for each of the 51 steps (50 LEDs plus the very top, the winner!). Actually, I’m not calculating this at all. I’ll let the Arduino do all the calculations, and save the delay value for each step in an array that it can quickly access when it needs to. Here’s how I did it in the Arduino script:

  float gravity_constant = 9.8;                         // the constant of gravity, or G
                                                        // we can adjust this to tweak the effect

  int gravity[50] = {};                                  // set up the gravity array

  for (int i = 1; i <= 51; i++) {                        // this will loop 51 times
    float distance_x = i * .035;                         // calculate the total distance from the top to the LED in question
    float distance_y = (i - 1) * .035;                   // same distance, minus one step 
    float time_x = sqrt(distance_x / gravity_constant);  // the time it takes for an object to fall distance_x meters
    float time_y = sqrt(distance_y / gravity_constant);  // the time it takes for an object to fall distance_y meters
    float time = time_x - time_y;                        // the time it takes for an object to fall to our LED from the one before it, in seconds
    int time_ms = time * 1000;                           // convert to milliseconds
    gravity[i] = time_ms;                                // add this value to the gravity array

The gravity array will look something like [59, 26, 16, 14, 13, 12, 11, 10, 9, etc…….], dropping rapidly at first and then slower until it levels off at 4ms or so. If we then light the LEDs in sequence, applying these delay values to each step:

  int level = 48;             // this is the level the person hit to
                              // * entered manually for testing purposes,
                              // in the final product this will be determined by 
                              // the force of the hammer strike  

  for (int i = level; i > 0; i--) {
    digitalWrite(ledPins[level - i], HIGH);
    delay (gravity[i]);
    digitalWrite(ledPins[level - i], LOW);

then we get something like this:

Note: the blinking at the beginning is the Arduino booting up, and the blinking at the end was added later to highlight the level of the hit.

everything’s better with fireballs

I never intended for the Selleck Striker to include fireballs. But this time last year we started thinking about fireballs for something else and got all the pieces together, so they were really just waiting around for something awesome like this. Here’s how it’ll work.

The fire itself is created by igniting “flash paper”, which is a nitrocellulose paper used by magicians to create relatively safe indoor fire effects in their act. Basically the stuff flares up and it’s gone… no burning embers, hardly any ash at all. It is fire, but you can basically hold it in your hand, it’s there and gone that fast.

The flash paper is ignited by a model rocket engine ignitor, which is essentially a tiny incandescent filament with some flammable paste packed around it. You apply 6-12 volts with enough current and it flares up breifly, but plenty long enough to light the flash paper. The Arduino can’t supply nearly enough current to light it, so I’ll end up using a transistor to switch a higher-current (and slightly higher voltage) power supply to the ignitor.

For now I’m just concerned with the hardware. I’d like to have a replaceable “charge” that can be unplugged once it goes off, and replaced with a fresh one. So the sketch below shows a small metal tube with a 1/4″ phono plug on one end that plugs into a matching jack behind the Tom Selleck head.


The tube is copper and the end fitting just slips on snugly, but everything else turned out just like the sketch:

For now I’m using a 9V battery touched across the plug’s contacts. The trick, it turns out, is packing the right amount of flash paper in the right way. It took  a few tries, but I think the third attempt got it right:

Hi-Striker control panel

Yesterday I finished the control panel for the Selleck Striker and started hooking it up:


reset button – Before a new contestant hits the striker, the reset button clears the LEDs, then checks the difficulty setting and applies any changes. It’s a SPST, switching 5V from the Arduino to one of its analog input pins. High on the pin = reset.

play/demo switch – Demo Mode plays a scrolling LED effect, Play Mode waits for a change in the pressure (like a hammer strike!). This is a SPDT (though I could have just used a SPST) switching 5V from Arduino to one of its analog input pins. High on the pin = Demo Mode, low on the pin = Play Mode.

analog_inputdifficulty knob – Just a 100K potentiometer that sends 0 to 5V to one of the analog input pins. This will allow us to adjust how much force is needed to get to the top.

score display – This 3-digit numeric LED display will show the “score” of the strike. I’m still not sure how I’ll calibrate it, but the idea is that you get a finer resolution score than the 0-50 LEDs in front. I’m thinking of having this also display the “difficulty” setting when you twist the knob.

striker connector – This is an RJ-45 connection for the striker portion, so that the two halves aren’t permanently tethered to each other. I’m only using three of the eight conductors.

audio out – This 1/4″ mono jack will send sound effects and other audio to the sound system.

Also note the the three Arduinos in the bottom of the photo. The Mega on the right will handle the LEDs and input elements, the NG in the middle drives the 3-digit LED display, and the Duemilanove with the wave shield on the left plays the sound effects. They’ll be communicating via their serial ports.

Arduino UNO


CNC controller – assembly & wiring

Assembly of the controller box has gone very well. The PC components (motherboard, hard drive and power supply) all mount to the monitor’s VESA holes through a flat aluminum bracket, and the monitor attaches right to the front panel. The keyboard gets sandwiched between a flat steel plate and the front panel, with some minor modifications to its silicone cover to make it fit.

small form factor PC and touch screen built into custom CNC controller box

The rest of the assembly revolves mainly around the PCBs and front panel controls. Before mounting the PCB assembly I installed the small USB daughter board that provides a USB port on the front panel.

USB daughter board for custom CNC controller box

The rest of the assembly mounts over this, aligning the tact switches to the button actuators. The remainder of effort went into managing the many wires neatly into the cabinet.

custom CNC controller box

The lower cabinet assembly was much more straightforward:

stepper motor drivers for G0704 CNC milling machine

stepper motor drivers for G0704 CNC milling machine

Of course I wanted to fire it up as soon as possible, even though nothing was connected. The Arduino IC was not yet programmed so none of the UI elements were working, but I was able to transfer files through the USB port.

custom CNC controller box for G0704 milling machine

This is far from complete, but I’m ready to start integrating the Mach3 software with the electronics and make sure they can talk to each other.

My First Robot, part 1

Isabell is ready for robots!

Isabell is ready for robots!

Several months ago I backed a Kickstarter campaign for Primo, a simple Arduino-based teaching tool for introducing programming logic to kids age 4-7. My oldest daughter was just 3, but my pledge got me plans and code only, and I figured the way projects go around here it just might be done by the time she’s 4. The Primo experience involves a cute (albeit simple) little robot named “Cubetto”, and right off the bat I figured I would modify some things to make him more… well, awesome. Little did I know of the rabbit hole I was about to tumble into.

As usual I started off with some sketches, thinking about what the robot could do aside from the Primo stuff. A suite of sensors would enable all sorts of behaviors, from simple (light seeking, line following) to more complex (play catch, drawbot). I would definitely enable a simple “radio control” mode, but I’m much more interested in autonomous (or semi-autonomous) behaviors. Isabell is obsessed with the Curiosity Mars rover, so it should definitely have some of that DNA. I also believe the rover should have some personality, so I’m looking into some simple dot-matrix display “eyes” that can communicate artificial emotion, and a simple speaker to give it a voice.




I’m focusing on a tracked design for now, so it can navigate a moderately challenging indoor environment. I love the idea of solar charging, or at least autonomously finding its own charging station. Of course it needs a camera so I’m drawn to the Raspberry Pi as a brain, which might also make remote control from an iPad relatively easy. I imagine the Rasp Pi might talk to one or more Arduinos, which can handle low-level functions like battery monitoring or distance sensors. I already have some small full-rotation servos, which will make the drivetrain simpler (vs. motor controllers, gearboxes, etc.).

My main guiding principle here will be flexibility/modularity, so features can be added or changed as we try things, get bored with them, imagine new uses, learn stuff, etc. Next step, start building the platform.