Making our own mini goal light
While waiting for some parts to arrive for an internal project at Res.im, I had an opportunity to revisit and experiment with some technology that I had only managed to find time to run demos with. These are small, microcontroller boards that can connect to WiFi – the tech behind the Internet of Things. Both the Spark Core and the Electric Imp connect to your network, and have I/O pins that can be controlled via the Internet.
In learning to work with new technologies, I find a project-driven approach most useful. I learn how to do things that personally matter with the tech, and the goals of the project bound my work with it. One project I’ve admired that relies on this web-connected technology is the Budweiser Red Light. Resembling the iconic siren that goes off when a goal is scored in hockey, these lights could be set up to go off whenever your favourite NHL team scored.
My son loves watching hockey, and his birthday’s approaching. His favourite team is the local OHL London Knights, but the Red Lights don’t seem to monitor OHL teams. Additionally, as great as the product is, I don’t think my seven-year-old needs a $150 beer ad. Instead, I thought it might be a fun project to make him his own mini goal light that worked for his team.
To make this, I broke it down into three main parts:
- a goal light,
- a networked controller to turn the light on and off remotely, and;
- software to monitor for goals and automatically activate the goal light.
For the goal light, I found some hockey goal light key chains. The red light spins and it makes goal horn sounds when the device is pressed. I wasn’t entirely sure how they worked, but they had the functionality I was looking for.
When the key chains arrived, I opened them up very carefully to see what was going on inside.
What was the switch activating?
How did it work?
The battery was a 3V coin cell, which was great because the Electric Imp and Spark Core could both supply 3.3V, so they should be able to power the light. I found the switch inside, and did some poking and prodding on the light’s circuit board to figure out what the switch was doing – was it connecting part of the circuit to ground, or perhaps pulling it high to activate the light?
Fortunately, there were extra pads on the circuit board that I could solder to, so I was able to add a line that would go from the pin on the microcontroller to the light’s circuit board to activate the light. With the battery removed, two more wires were added to the battery terminals, and wired to the power supply and ground from the microcontroller. A battery pack could power the microcontroller, which would provide power to the light.
For the microcontroller, I opted for the Electric Imp. It was quickest to embed in the project, as the development board for it didn’t have header pins pre-attached. It also had large, accessible pads to solder the battery pack to, and the power, ground and pin outs were easy to attach to. The Spark Core is laid out very well for prototyping, with header pins installed to make it easy to work with on a prototyping breadboard, but that wasn’t needed for this project. Additionally, I found that activating and changing the state of pins on the Electric Imp via custom URLs a more direct route than using cURL and GET, POST commands that the Spark Core requires.
The last piece is the software that actually monitors the score during a game. Processing has become my go-to IDE for prototyping, so I created a small program that will periodically check the score of the game at the team’s website. For each game, there’s a text page that gets updated with details of events from the game. The program basically loads that page, does some parsing of the information on the page to isolate the goals scored by London, and then watches for changes to that score. When the London Knights score, the goals get updated on the page, the software notices the change, and the program visits the URL that activates the light. The siren goes off, flashing and honking for the goal.
Processing includes a framework for generating Android apps from Processing code, so I also used this project as an opportunity to create a custom app to do the behind-the-scenes automation. Now, when a game is starting, I can configure and run all of this from an Android app on a tablet that’s set down while we watch the game.
To finish off the project, I drilled a couple of holes in a small project case. A switch was added to one so the whole thing could be turned on or off. The three wires added to the light were passed through the centre hole, and the light mounted over top of it. Finally, I picked up an enameled logo pin, and fixed that to the case. Small rubber feet have the box sitting off the table. My son can hold it or set it where he likes while a game is on, ready to cheer at the next goal.