Stokes’ ProjBlog

A journal documenting innumerable, mostly terminally in-progress undertakings. Nerdiness abounds.


“STAND BY FOR MIND CONTROL!” October 29, 2013

Filed under: Miscelaneous Projects — Stokes @ 8:02 pm

MindFlex to Serial to USBA couple of years ago, I bought a toy EEG reader: a Mattel MindFlex, one of several that use the same NeuroSky chipset. Toy it may be, the tech at its heart is really quite remarkable. I have a vague understanding of how it works, but that just makes it seem even more like magic.

The NeuroSky module itself generates 9600 baud serial data. The MindFlex headset transmits wirelessly to a base station, but the data sent has been heavily munged; I assume this is because the transmitter module they use is slow but cheap. I hacked the hardware shortly after I got it (adding a little chassis-mounted 3-pin socket to access the chip’s serial output, the battery, and ground), but for one reason or another, I ended up forgetting about it until recently.

So far, I’ve created a Python library for handling NeuroSky data; it’s on github now. I’ve also turned the headset into a Bluetooth device. I’ll post more about that later.


Hanging on the Telephone, Part 2: the Code September 26, 2013

Filed under: Miscelaneous Projects — Stokes @ 3:05 pm

Rotary Dial w/ DigisparkTurning a rotary telephone dial into a USB device was easy. As I (re-)discovered, the dial is basically just a pair of switches: a normally-open ‘dialing’ switch, which closes while the dial is in motion, and a normally-closed ‘pulse’ switch, which opens and closes the same number of times as the number dialed. All I needed to do was count the number of pulses that occur while the ‘dialing’ switch is closed, then send a USB keypress event based on that number when the ‘dialing’ switch opens again.

I used a Digispark for this project, so the code reflects a few of its oddities. In order to cram software USB emulation onto a tiny microcontroller and still leave room for user code, they had to make some compromises. There are no interrupts available, and their own version of the delay() function needed to be used to keep everything in sync. The hardware side is also a little odd: because the Digispark’s main header doesn’t provide a ground connection, I just set one of the digital I/O pins LOW and used that. This seemed like a hack at the time, but I later saw this technique on one of Digistump’s own lists of power user tips, so I don’t feel so bad.


Hanging on the Telephone September 25, 2013

Filed under: Miscelaneous Projects,New project! — Stokes @ 2:04 am

rotary-dialWith the Atari keypad working, I want to adapt another old input device to work with modern machines. I’m going to set my sights a bit further back this time.

When I was in my single-digit years, I was given a broken telephone to play with: a standard Bell desktop model with a rotary dial, nearly identical to the other phones in the house. I discovered that a flashlight bulb and battery could be wired to the dial so that the bulb would blink when a number was dialed. Not just blink, I noticed: blink the same number of times as the number dialed. I also noticed that the bulb was normally on, and would wink off when dialing — the opposite of the way I expected a switch to work. These observations lead me to discover that a real phone could be dialed by quickly tapping the switch hook. I suspect I dialed a few wrong numbers during my research, but I was so thrilled by my discovery that I can’t remember them now. I may not have noticed them then, either.

My new project: create a USB rotary numeric ‘keypad.’ I know this has been done before, but as a tribute to my early experiments, I’m going to do mine without any research from the ‘net. This will be a purely experimental venture.



Check Out my (Atari Key-)Pad, Part 3: Making it Work September 11, 2013

Filed under: The Atari Keypad Project — Stokes @ 11:13 am

Keypad HookupNote: for some reason, something in the combination of the code listings in this post, the syntax highlighter I’m using (Crayon), and my theme causes rendering problems in some browsers. I apologize if parts are difficult to read. I’m looking into it.

To recap: In part 1, I figured out how the CX85 keypad works and how it’s wired; in part 2, I made a change to the Arduino’s HID library that will give me more control over the keypad emulation. Now, to write a sketch to drive it!

Hooking the keypad up to an Arduino Leonardo was trivially easy. I used a male DB9 on a ribbon cable, the serial port from an old computer. A simple breakout board (the most complex part of the setup) just widens the 2×5 header connector enough to fit across the gap of a breadboard, DIP style. I wired it to the Arduino somewhat out of order:


Check out my (Atari key-)Pad, Part 2: HID Hacking September 9, 2013

Filed under: The Atari Keypad Project — Stokes @ 12:05 pm

Modifying the HID APIOnce I figured out the hardware inside the Atari CX85 keypad, all that was left was the software. And by “all that was left,” I mean the remaining 90% of the work. Not long ago, getting a microcontroller to emulate a USB human input device for a prototype would have been an ordeal. With the introduction of boards like the Arduino Leonardo, however, this is almost as easy as writing any other Arduino sketch. Almost.

For some reason, the standard Arduino library offers only limited keyboard emulation. You can ‘print’ characters as key presses, but you can’t send specific key codes: you can send the character 9, which comes out as the 9 key at the top of your keyboard, but you can’t send the number pad 9 key. This can be easily fixed, but it requires modifying part of the Arduino’s standard library.



Check out my (Atari key-)Pad, Part 1: Hardware Archeology September 2, 2013

Filed under: New project!,The Atari Keypad Project — Stokes @ 2:27 pm

Atari Keypad to USB A while back, a surplus electronics catalog was offering vintage Atari numeric keypads. Specifically, it was the Atari CX85, introduced sometime around 1982, intended for Atari 800 computers*. I have a thing for input devices, so of course I picked up a couple. It’s a hefty unit, housed in 70s/80s earth tones, with the ubiquitous Atari unshielded female DB9 connector. Its 17 keys have a nice, chunky feel to them. My goal: get this keypad attached to a modern computer — without any permanent modifications.

One thing leapt out immediately: 17 keys. I had to recount them to make sure I wasn’t seeing things. 16 keys is typical of a keypad, with keys wired in a 4×4 matrix. Having a prime number of keys is kind of bizarre. My initial thought was that maybe it contains a 4×5 matrix and some number of possible keys are just left out; that would fit a 9-pin connector, but I realized that the keypad has to be compatible with the Atari joystick port. In addition to +5V and ground pins, the joystick port has only five digital and two analog pins: the four cardinal directions, the ‘fire’ button, and paddle inputs. What’s more, the pins are input-only, so unless the keypad switches are DPST (unlikely), there’s no way the computer could scan the keypad (supplying power to each column or row to see which button is pressed). There had to be some logic in there.


Putting the Broken in Breakfast July 20, 2013

Filed under: Miscelaneous Projects — Stokes @ 5:38 pm

A couple of years ago, I was part of a team that attempted to build a Rube Goldberg-style breakfast-making machine, part of the Take On the Machine hackerspace challenge. I posted the two Artisan’s Asylum segments, but the site that originally hosted the videos appears to have dropped them. Today, I rediscovered the videos on YouTube!

See the videos now!


Introducing MusicMover! July 15, 2013

Filed under: Miscelaneous Projects,New project! — Stokes @ 2:17 pm

MusicMoverThe situation: I wanted to keep the music collection on my phone fresh. I use iTunes since I have a Mac and an iPad, but my phone is Android-based. This wouldn’t be a problem if my phone had enough storage for my entire library — I’d just copy everything and be done with it — but I have many times more music than my phone has space. iTunes will do some stuff to randomize the subset of music on an iOS device to fill available space, but there’s no simple bridge to Android.

The solution: MusicMover. I put together a moderately simple Python script that reads the iTunes library XML and copies tracks (to a specific total size or minimum free space) to my phone when I mount it as a USB drive. It doesn’t just copy, though: it replaces (by default) a third of the music already on the phone with fresh tracks.

It’s a fairly bare-bones, but it gets the job done. As it stands, it’s a command-line utility, with an optional Tk progress bar display. Since it may be of use to others, at least as a starting point for their own projects, I’ve put it on GitHub. I’d like to see what other people can do with it.


Junk Box DrawBot June 13, 2013

Filed under: Miscelaneous Projects — Stokes @ 2:59 pm

Junk Box DrawBot, Front (?)Someone in the Introduction to Arduino class I teach at Artisan’s Asylum asked me what could he actually do with the knowledge and materials I supply. As an answer, I built a robot, using materials from class and random parts in my junk box.

It took maybe 90 minutes to construct, nearly half of which was simply rooting around for just the right part. I might have done it in less time if I’d used proper tools; all I used was a power drill, a nibbling tool, and a needle file, things I had readily available at home.


A real pain in the neck September 5, 2012

Filed under: Miscelaneous Projects — Stokes @ 1:12 am

Quick-and-dirty laptop standI’ve been working on my laptop on the couch quite a lot, and it’s started to cause me real problems. I’ve been getting intense ‘thunderclap’ headaches, and they appear to be a posture-related injury: slouching on the couch, looking at something in my lap has done something awful to my neck. To improve things, I’ve started spending my day working at Artisan’s Asylum, where I set up on one of the electronics shop benches. That’s better, but looking down at the screen is still aggravating my neck, so I put together a quick-and-dirty laptop stand out of yet more scrap wood and junk bin hardware.

The sides are part of an IKEA spice rack, and the other metal parts are server rack-mounting hardware. Thumbscrews on either side permit adjustment of both the height and the angle.

My neck is already feeling better.