All posts tagged Arduino

Highchair Blinky

Here’s my third baby/toddler blinky toy, and first official entry to the canon of IKEA hacks… the blinking high chair, aka the Antiloputer.

This is four arcade buttons and four smart full-color LEDs, drilled into an IKEA Antilop high chair (a spare tray is $5). The brain is a 5v Adafruit Pro Trinket, powered by four AA batteries.

The default mode is the same as the blinky my dad made for me long ago: press the red button and the red light lights up, press the green button and the green light lights up, and so on.

Holding down all the buttons at once lets you switch modes: mode two is like mode one, except each light stays on until the next one is pressed. Mode three is like a typewriter, and mode four is a step sequencer.

This was my first time programming with the FastLED library to control the LEDs. Download the code here.


I suspect the high chair wouldn’t make it through airport security — below is what it looks like inside… Normally, baby legs are protected from the electronics (and vice versa) by a piece of heavy cardboard.


The buttons are attached between the regulated 5v power rail on one side, and pins 10-13 on the other, with a 10k ohm resistor running to ground from each. The LED data is on pin 9, and power for the LEDs also comes from the 5v power rail, through the Trinket. I did this since the 6v coming directly from the batteries is too much for the NeoPixels.

The Trinket can only provide 150 mA, which is pushing what four LEDs will draw at max brightness. Fortunately, the FastLED library has a line where you can specify the max current, and it will dim the LEDs as needed. Genius.


The LEDs are below the high chair tray, aimed up through small holes. I hot glued translucent plastic containers from an art store over the holes, which glow nicely. Be warned, babies are stronger than hot glue, although there’s no danger if the containers get ripped off. You could probably skip the holes and containers, since the LEDs are bright enough to show through the tray.

Also check out the BABYTRON for more blinking.

(Wire) Stripper Cake

This is a case of knowing your audience: my friend Matt is deeply involved in the world of creative DIY electronics, and appreciates a good (ie. terrible) pun. So for Matt’s bachelor party, fellow groomsman Ethan and I arranged for a stripper to pop out of a cake — but in this case, it was a wire stripper (an electrician’s tool) animated by a jumble of electronics, in a cake which we built.

After dinner, we lit the candles on the cake (it was also Matt’s birthday), and in the dim light of the BBQ joint, the illusion was convincing.


But once Matt made his wish and blew the candles out, the top opened up revealing a stripper dancing on a stage, complete with flashing lights and music!


The cake’s frosting is a sheet of white foam material from an art store, held on with Velcro stickers. The decorative chocolate frosting is brown caulk.

Beneath the frosting is a laser-cut plywood frame, with threaded dowels, nuts and washers. The top has a hinged lid with the stage slotted and glued inside.


Cake plans
Cake plans
Cake plans

A hidden power switch in the back provides 6V from four AA batteries to an Arduino Duemilanove microcontroller, which we programmed to run the show.


First, all the lights flash red, as a motor with built-in gear reduction box pulls a string attached to the lid’s counter-lever, opening the lid and raising the stage. (We used this motor driver).



Once the stage is up, the lights change to a cycling rainbow pattern. We used four of Adafruit’s 8-NeoPixel strips, all chained together in series. The first NeoPixel strip is on stage, lighting up the wire stripper.


Other NeoPixel strips are on the middle ring, lighting the inside of the cake in all its mad scientist glory. The white foam frosting is translucent, so the whole cake glows brightly on the outside.


Beneath the stage, a motor with an elliptical wheel makes the wire stripper kick its leg and dance the can-can.

The original plastic geared motor for this section melted when we tried to solder on the power cables. The Radio Shack replacement didn’t have enough torque. So we used a spare littleBits motor. It later burned out because we’d run out of time and didn’t regulate the voltage, but by then it had done its job.


Music is from a chip I ripped out of a greeting card years ago, wired up to a small speaker. It plays the theme from “The Good, The Bad, and The Ugly.”


When you’ve had enough of the show, you can reach in through the top and press a microswitch (center of the picture, on the middle ring), which stops the dancing, turns all the lights to blue, and closes the cake up again.


We built the whole thing in very little time, and it has a cobbled-together, hot glue aesthetic. Not the finest engineering, but Matt loved it, which is all that matters.


Azimuth Video Installation

Azimuth is a video capture and playback installation with simple wireless controllers. It’s based on the Déjà View Master, modified for the art show “Being and Time.”

The basic layout is a webcam feeding into a Mac Mini running a Max/Jitter patch, controlled by three wireless Arduino-based devices, and displayed on two monitors: a Zenith television on a table, and a projector mounted under the table, projecting onto the floor.


The screen normally displays a frozen image of the empty room. As you turn the clock-like controller, you scrub back and forward through a constantly-recording half-hour video buffer. The frames flash on screen as long as you’re moving the hand, but it fades back to the frozen frame when movement stops.

To add an element of unpredictability, it sometimes scrubs through a pre-recorded video of walking to the venue, or operates normally but with the image sliding off the TV and onto the floor via the projector.

Jitter works by using a matrix of pixel information to manipulate video. In Azimuth, the video buffer is accomplished by recording sequentially-numbered Jitter binary files (each matrix file is one video frame) to a hard drive, and separately reading the matrix files back and displaying them. Once the maximum number of frames has been written, the counter resets and writes over the first frames, letting you record in a loop.

Here are the basic components of this operation, set to record one minute at 15 fps (900 frames), and read back and display other frames, chosen by the number box on the right.


Grab this Max patch here


There is more math involved in keeping track of the current frame and rolling back through zero.

The projection on the floor is black, but image appears where the camera picks up movement. The patch subtracts the 8-bit value of each pixel of the previous frame from the current frame: where the pixels are the same, the value will be zero. Where the value is different, it will light up. It’s like velociraptor vision.


The button controller swaps the output monitors, putting the frame differencing on the TV screen and the freeze frame on the floor via the projector. The frame differencing is quite popular: the kids love dancing in front of it. But it has a practical function too. Part of the Max patch adds up the value of all the cells in the frame to determine whether anyone is in the room. The more movement, the higher the total value. If the number stays below a set threshold for more than a few minutes, it will assume that the room is empty and update the freeze-frame.

The other control box has a knob, which switches between five channels. Some channels read back from other matrix “banks,” where the five-digit matrix file begins with a different number. The main video loop is 10000-17200 (add 10000 to the counter value, max of 7200 for 30 minutes at 15 fps), a busy time saved from the show’s opening is 20000-27200 (add 20000), a pre-recorded movie of riding the subway and walking to the venue is 50000-53400, and so on. Another channel adds vertical roll to the live video feed, like an old TV. All adjust the brightness and color in some way.

Any controller will take over whatever’s happening in screen, and the result of pressing the button or knob will time out and revert to the empty frame if left alone.


The boxes are all handmade oak frames with laser-cut semi-transparent acrylic front and back, echoing the Zenith television.

The big box has a rotary encoder with a clock hand attached, so it can spin continuously in either direction. The encoder is connected to a Teensy 3.0 microcontroller which runs Arduino code. It sends one command repeatedly if turned clockwise, and another command if turned counterclockwise, via a serial connection with an XBee wifi radio and adapter.

It’s powered by a 2,500mAh lipo battery (the Teensy and XBee operate at 3.3v), and uses Sparkfun’s Wake on Shake as a power switch. This device is brilliant. It has a gyroscope, and turns on if there’s any movement. It then stays on as long as there is power going to the wake pin — this comes from one of the Teensy pins, which is programmed to stay on for 15 minutes after the last time the controller’s been used.

I used a breadboard with power rails removed to hold the Teensy and XBee, since it provides a flush, solid connection. Double-sided tape, industrial strength Velcro, and hot glue keep everything in place. The back panel is held on with machine screws.


The smaller boxes are similar, but use an Adafruit Trinket for the logic. One has a 10k linear potentiometer, and the other uses an arcade button. Each has a panel-mount power switch on the bottom of the box.


The receiver uses a Teensy 3.1, which relays incoming serial messages from the XBee to the Mac Mini over USB. I’d normally send a serial connection directly into Max, but since this installation needs to run reliably without supervision, I set the Teensy to appear as a standard keyboard. Messages from the controllers are sent as keystrokes, and the Max patch responds accordingly. This also made programming easier, since I could emulate controller action with keystrokes.

The receiver is housed in a spare Raspberry Pi case with a hole cut in the top for the XBee. I also added a kill button to stop the patch from running and quit Max by sending another keystroke. The Mac Mini is set to launch the Azimuth patch on startup, so between that and the kill button, no keyboard or mouse is needed from day to day.

Arduino code for the controllers and receiver is here.


The Mac Mini connects to the Zenith TV via a series of adapters: mini display port to VGA, VGA to RCA, and RCA to RF (on channel 3). The projector is configured as the second monitor, with a direct HDMI connection. I don’t recommend working on a complex Max patch on a 640 x 480 screen.

All in all, the installation runs well. Video is stored on a solid state laptop hard drive in a USB 3 enclosure, and most of the video processing happens on the GPU using the Gen object ( in Jitter. Some people were tentative when using the controllers, but others dove in and had a good time.

Blinky Love Note

I made a blinky love note for my sweetheart this Valentine’s Day, because what’s more romantic than Morse code?


A single LED paints a 6″ x 6″ canvas with light. It first tells a story through color, and then slowly pulses a secret message in Morse code, fading from deep to light pink.

The smart LED is run from a 5v Adafruit Trinket, powered by 4 AA batteries. Download the code here. (This just blinks “hello world.” The secret message will remain secret).

LED Strip Clock

I just put together a clock with Adafruit’s 60-NeoPixel LED strip, running off a Teensy 3.0 microcontroller. The flexible 1-meter strip has 60 RGB lights, so different colors represent the second, minute, and hour — you can read it like a normal clock if it’s in a circle, but you can also leave it in a straight line or drape it over something for the Salvador Dalí look.

Version 1 of the clock code advances the second using the delay() command, and moves the minute every 60 seconds and hour every 60 minutes. It’s a good exercise in procedural logic, but loses time quickly.

Version 2 uses a crystal soldered directly onto a Teensy 3.0, which will keep time if you attach a watch battery. Look at the Teensy Time Library page for more info.

The LED clock lets you pick different color schemes, add faint dots every 5 or 15 minutes (or none), and turn on blinking hour “chimes.” Right now you need to set these options in the Arduino IDE and re-upload, but I’ll add the ability to change that with buttons or a knob at some point.

View or download the code here.


I don’t have any pictures of the final clock in action — I gave it to my dad.


[UPDATE 5/24/14]

I’ve discovered some design problems with this project. First, Adafruit recommends adding a capacitor between the – and + on the NeoPixel strip, and a 300 to 500 ohm resistor between the Teensy’s data pin and the NeoPixel data-in (at the NeoPixel end of the connection). This doesn’t affect the clock’s performance, but protects the NeoPixels from damage.

Second, I’ve gotten reports from someone who built this project that occasionally the second-hand LED stays on until the next time it passes by. I got a lot of glitches the first time I had v1 hooked up, but that got resolved when I used a different power supply. But the Teensy 3.0 uses 3.3V logic, and the NeoPixels are powered at 5V.

The Adafruit NeoPixel Überguide says that the data has to be at least 70% of the power or its message will get lost, and 3.3V / 5V is 66%. Close enough to work most of the time, but I’m guessing that the glitches occur when the signal doesn’t get through.

The best thing to do is add an I2C-safe Bi-directional Logic Level Converter to boost the 3.3V data to 5V. But if you’re using a Teensy 3.1 which has 5V tolerance on all digital pins (and presumably won’t get damaged by talking to a 5V device), then try this revised code for v2. I added redundancy to the erase and write message, to give it a better chance of getting through.

I’m checking to make sure that, glitches aside, nothing will get damaged with this setup. Stay tuned…

LED Candle in a Jar

I’ve been wanting to create a small light with realistic fire animation, so hot off the workbench in time for mid-winter: a flickering LED candle.

Its brain is a programmable microcontroller, running a smart RGB LED via a single data pin, housed in the lid of a jar. I used Adafruit’s Atmel-powered Trinket — a tiny, inexpensive board available in 3.3V or 5V flavors.

Here are three prototypes:

1) A self-contained 3.3V candle with a single Flora NeoPixel, powered by a tiny rechargeable 150mAh lipo battery inside the lid, with a pushbutton toggle power switch hot glued to the outside of the lid.


2) A 5V single-pixel candle, with Trinket on the outside for powering via USB, plus an extra 2.1mm socket for external wall or battery power. I used a nail to punch holes in the lid for the wires, and a diagonal cutter for the power socket. The Trinket is held down with hot glue.


3) A 5V 8-pixel candle using Adafruit’s 8 NeoPixel Stick, with all electronics inside the lid and a 2.1mm power socket on top. The Trinket can handle 150mA output, which is right around the stick’s draw when all pixels are set to candle flame yellow (R=255, G=100, B=10) — but the stick jumps over 200mA when fully lit, so it gets its power upstream from the Trinket.


The jars have a white paper disc at the bottom and a tracing paper tube running the jar’s height. I plan on replacing them with some theatrical lighting diffusion so nothing bursts into flame — probably not a risk, but you never know.

The Arduino code runs a basic fade on the green pixel, causing it to dip down and back every 120 milliseconds, roughly 8 times per second. When the green dips, the light gets dimmer and redder, as if it’s losing oxygen.

An RGB mix of 255, 100, 10 (on a scale of 0 – 255) looks like a pretty good candle flame yellow to me. The starting green pixel value is “grnHigh.” You then set how much below grnHigh the green pixel should dip for normal burning, and when it’s flickering more. “grnLow” is grnHigh minus the dip value.

The main function is a basic for-loop, called fire()

void fire(int grnLow) {
  for (int grnPx = grnHigh; grnPx > grnLow; grnPx--) {
    strip.setPixelColor(0, redPx, grnPx, bluePx);;
  for (int grnPx = grnLow; grnPx < grnHigh; grnPx++) {
    strip.setPixelColor(0, redPx, grnPx, bluePx);;

So green starts at grnHigh, the max green value, and decreases until it reaches grnLow, then goes back up again. fDelay is calculated by doing some math with the number of steps to keep the cycle time constant.

The next set of functions all call fire() with adjusted dip and delay time. Your options in increasing amount of animation are: on(), burn(), flicker(), and flutter().

The main loop just looks something like this, with the variable as the number of seconds you want each animation to run:

void loop() {

The Adafruit NeoPixels officially run on 5V, but according to the power page of the Adafruit NeoPixel Überguide, small numbers of NeoPixels can run off 3.7V. (I’m powering them from the 3.3V pin on the 3.3V Trinket, and it seems to work). The thing to consider is that green and blue pixels draw more power, so they’ll be dimmer and the whole RGB effect will be warmer. So grnHigh, bluePx, burnDepth, and flutterDepth all need to be tuned higher for the 3.3V version. I eyeballed 3.3V next to 5V, and include both values in the sketch’s comments.


For the 8-pixel strip (above), I created a color and flicker-depth gradient that was more exaggerated toward the top, and not at all at the bottom. It’s supposed to look like the flame height is dancing. It looks more convincing, but the portability of the battery-powered 3.3v model’s pretty nice — and the lid fits on any Ball jar (below).


Get the full code here:

Deja View Master

The Déjà View Master is an interactive video installation for situations where people and their attention wander over the course of an evening. The audience uses a clock-like wooden controller to rewind surveillance video back from a live feed to some-time-before.


There are two parts: a surveillance camera and TV monitor, recording video on a Mac running a Max/Jitter patch, and a wireless wooden controller sending position data to the computer, to move the playhead.


Recording and Playing

The Max/Jitter patch takes video from a USB webcam and writes the camera feed to a hard drive as matrix files (.jxf), one per frame, while simultaneously reading them back for display on an external monitor (via a cheap VGA to RCA adapter). The files are numbered serially, overwriting the earlier files once a limit (time or drive space) is reached.

This is basically just doing what a DVR does, although it took a bit of figuring to get it running on an updating loop in Max.

The current frame (“now”) is set by a counter which resets at the maximum frame count. When the controller is set to display “now,” the live feed is actually reading the “now”-1 frame. As you dial the controller backward, it subtracts an appropriate number of frames from the current record frame, rolling backward through zero, until the earliest point of the recording is reached at “now”+1.

I added a video effect which becomes more visible the farther back in time you go — initially it was a feedback loop which caused motion blur, but I finally went with more visible and less processor-intensive black-and-white, with increased brightness and contrast. I’d still like to add a blur or luma increase during scrubbing, independent of distance from present, but that’s for a future version.

The matrix files recorded to a solid state USB 3 hard drive. I also added a rotate 180 degrees function (jit.rota) for when the incoming webcam is clamped upside down to the ceiling.



The controller is the fun part. It’s a wooden box resembling a clock, with a wooden hand which controls the playback.

The design was inspired by the Pimoroni Timber Raspberry Pi enclosure, using stacks of laser cut wood. I used 1/8″ ply, which ended up taking close to an hour of laser time. It turned out well, but I might go for a different approach next time.

The face and back are 1/32″ veneer finished with Briwax, which allow two hidden LEDs to shine through (“now” and “before” indicators).

The clock hand is attached to a linear 10k potentiometer, which is wired to a Teensy 3.0 development board running standard Arduino code (take a look at the code here), powered by an 850 Ah lipo battery (it’s a 3.3V system). The Teensy sends serial data to the Max patch via a pair of XBee radios; the receiver XBee is attached to the recording computer with an FTDI cable and XBee adapter kit. The whole thing is mounted on an Adafruit perma-proto board.


George Del Barrio invited me to premiere the Déjà View Master at Vanderbilt Republic’s 2013 Art From The Heart photography show and event, curated by Renwick Heronimo. I had it set on a 70-minute loop, with the camera clamped to the ceiling, and monitor behind a transparent corrugated wall.

I may experiment with other controllers in future versions. The original idea was to use the position of a beer on a bar as the playhead, but I could see that ending with spillage. The wooden controller is pretty intuitive, as long as it’s obviously associated with the monitor. Another alternative to the current design is to use a radial encoder, so the hand can keep spinning as you wind through time.

Also check out the Photographic Monument that I programmed with Mark Kleback for the show.

[UPDATE 3/23/14: The Déjà View Master has evolved into Azimuth for the “Being and Time” art show.]