Stokes' ProjBlog

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


Buttoning down security November 1, 2015

Filed under: Miscelaneous Projects,New project! — Stokes @ 3:41 pm

iButton Reader 2My employer recently rolled out new security policies, including stricter requirements for passwords. As often the case, strong passwords using the new scheme can be a bit difficult to remember, and the unnatural mix of symbols makes them slow to type. A system with less strict password rules paired with a physical key (the “something you know/something you have” combo) would be more secure and convenient, but it is usually something that needs to be rolled out at a company level. I came up with a compromise.

iButtons are kind of a cool technology, albeit one that never made it out of certain niche markets. Basically, iButtons are 1-Wire chips in ruggedized packages similar to coin cell batteries. They only need two connections — combined data/power and ground — so the battery form factor works well. iButtons have unique 64 bit IDs and can join a 1-Wire “MicroLAN” with just a touch to a reader. I’ve had an assortment of 1-Wire and iButton hardware for a long time but never found a good use for it… until now.


My brain made me build a robot. June 1, 2015

Filed under: New project! — Stokes @ 3:20 pm

SonarBotA while back, I was held hostage by my own brain: it refused to let me sleep until I got out of bed and built a robot.

What prompted this was the delivery of some cheap ultrasonic range finders I’d bought. I wanted to try them out in a project; something more interesting than just displaying the distance measured, but not so complex that the range finders became secondary to the rest of the project. Eventually, I came up with an idea for a robot which was both simple and interesting. Unfortunately, this idea came to me while I was on the verge of sleep. The idea was a little too interesting: my brain refused to stop working on it, ultimately issuing its ultimatum. No robot, no sleep.

As usual with these spur-of-the-moment projects, I hacked the robot together from materials I had on-hand; the majority of my time was spent digging through my junk bin for suitable parts and matching screws. The final robot is a combination of random bits including PC case hardware, vintage Erector Set pieces, and a small bit of furniture-grade hardwood, atop a set of toy tank treads and powered by a twin gear motor. All in all, the robot’s body is somewhat unremarkable, other than having been assembled from junk by someone half asleep. The robot’s ‘brain,’ however, is much more interesting.


“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.