Rob Scanlon's Blog Just some things keeping me busy on the weekends

Python Light Controller

Sometime around Thanksgiving this past year, my brother asked me to help him add some special lighting effects to the party that he was DJing down in New York on New Years Eve.

Traditionally, a party of that size may use a set of automated, standalone light that automatically move/rotate/flash in synch with the music. Its not a bad effect, but he wanted something could he could also pre-program and queue during the show. Unfortunately, the next step up would involve expensive DMX controllers and lights intended to be used in clubs or larger music venues. Those were well out of his price range, so he asked me to put something together that provided more control than the stand-alone option, but was substantially less expensive than the commercial-level options.

Turns out I’ve been looking for a hands-on electronics project. I’ve always enjoyed web programming, mainly because it enabled me to reach a massive audience almost immediately. But I’ve also really like the idea of building software that has real-world effects, and where the interfaces is not just a traditional screen. I’ve been following the DIY community, which has really exploded recently due to the dropping prices of the components needed to put things together. This seemed like a good opportunity to get into this community.

Given the short time-frame, I think it turned out pretty well:

The overall system is pretty straightforward. The computer acts as the controller, and provides a user interface to the DJ. The DJ can trigger trigger light patterns to play or manually turn individual lights on/off through this user interface. The computer is connected to a relay, which controls the flow of electricity standard AC outlets. The lights (or theoretically any appliance that draws less than 5amps) can be plugged into these outlets.

Since I hadn’t built electronics since undergrad, I chose to keep the hardware portion of this project as simple as humanly possible. That led me to choose a design that used a parallel port relay kit to control the lights. That limits the number of channels I could use to 8, and it also meant that the lights could only be switched on/off (no dimming). And it limited us to using a computer that actually still has a parallel port. I found a pretty good example of somebody that was doing something similar, which I ended up mimicking pretty closely.

I’m glad I went through the trouble of assembling the kit myself. Besides costing half as much, I got pretty good at soldering, which came in very handy when my TV broke a few weeks later.

The software portion of the project was a little more tricky than I originally had anticipated. The original concept was to connect the soundboard to the computer, which would then synchronize the current programmed pattern with the music. I simply didn’t have time to learn enough theory and the necessary audio interfaces in the few hours I had to dedicated to this project to do this. So instead, the interface would allow the DJ to trigger a set of patterns by keystroke, which could be overlayed on top of each other if desired. Then on top of the playing patterns, the DJ can turn individual lights on/off.

As a side note, I chose to program this in python, because I haven’t had an opportunity to use it yet.

The top row of lights show the lights that are on through manual control, while the bottom row of lights show the lights being played in the current pattern. You can download the source at on github. Of course, use at your own risk.

There is definitely a lot of room for improvement in this application. If I spend more time improving it I’d probably work on the following:

  1. Use USB or wireless instead of parallel port
  2. Add feature detection of current playing music to synchronize music with lighting
  3. Add the ability to dim lights, instead of simply turning them on/off
  4. Add more than 8 channels