All posts tagged tinkering

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.

pixelclock1

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

pixelclock2

[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…

Atari Asteroids Controller: Backstory

Years ago, I picked up scrapped parts from a 1979 Atari Asteroids arcade machine: a metal control panel, original buttons, and a screen-printed marquee — and then set out to wire them up to control Asteroids on a computer.

01_console_top

The buttons are the trick. They’re just a simple electrical circuit, two contacts pressed together, which need some way to speak in ones and zeroes to the computer. The simplest approach is with a keyboard encoder, so the computer will see button presses as standard keystrokes (as opposed to running additional software to interpret the signals).

In the spirit of hacking together spare parts, I ripped the circuit board (encoder) out of an old Apple Pro Keyboard, and wired it up to the arcade buttons. The keyboard is set up in a 12 x 20 matrix, where combinations of circuits create the different keystrokes. I labeled the contacts on the left “A” through “L,” and contacts on the right “1” through “20,” and with the USB end plugged into a computer, started touching all combinations of the contacts with a wire. Here’s what I came up with:

apple_pro_keyboard_matrix
Click here for a tab-delineated text (right-click or alt-click to download).

04_kbd_hack_finished

I mounted the final version on plywood. Dowel rods held the contacts in place, although an X-Acto knife and some flux improved the solder points later on.

On the computer end of things, I downloaded MAME (arcade machine emulator) and the ROM (software image of the arcade game’s data files) for Asteroids. The Asteroids control panel worked like a charm.

A month later, I bought a commercial keyboard encoder from Hagstrom Electronics, knowing that I’d want to be able to wire up contacts for other purposes like triggering video playback. Here’s the final version of the Asteroids controller, using the Hagstrom encoder with breakout board:

02_console_finished_under

I didn’t end up using it that much, partly because Asteroids just isn’t the same without a real vector display, and partly because the metal panel is kind of huge and awkward. I also started using more programmable or pre-built options (Arduinos, MIDI controllers) for my I/O needs.

That said, it was a good first project to learn about controllers. Years later, I made a smaller, self-contained, desktop-friendly Asteroids panel — read on to learn more.

(A nod and thanks to Machine Project in LA, whose workshop on building homebrew arcade machines offered valuable info. Also in SoCal is Vintage Arcade Superstore, with a warehouse full of old arcade parts.)