This weekend I put together a marble run for my kids in an attempt to win their favor for a time. I glued the magnets to the backs of pieces of wood and PVC pipe. I also had an old vacuum hose that was not yet thrown away (despite my wife's best efforts). These pieces could then be positioned on any metal surface and the mouse balls rolled down them. The most convenient surface was the front door and my children have been playing with this toy made out of garbage for a week non stop. Definitely a success.
I wanted to add a component that would light up when the ball rolled through it.
First, I considered using an IR or capacitive sensor to trigger a microcontroller to light my lights.
This was a little overkill. I wanted the project to run for a very long time on small batteries and polling a sensor would be a waste. The natural solution would be to use a simple mechanical switch. The mouse balls were not heavy enough to trigger any of the microswitches that I had on hand so I started to think of what I could make homemade.
My first prototype attempt was to create a strip of pressure switches. These consisted of a strip of foil for one side of the connection and a coiled wire for each LED. A straw was used as a spring to keep them separated. This configuration worked as a switch but it was mechanically impossible to get the mouse balls to trigger the switches.
The design that worked was to hang the switches from the top of the PVC pipe.
It is important to be able to insert all the switches as one unit because assembling anything inside of the pipe is well beyond my fine motor skills. The switches were constructed on a strip of cardboard and could easily be inserted and removed.
One lead of each LED is tied together and to +3V from the battery. The other lead of each goes to the switch. I fashioned the switches out of paperclips. The triangle at the top of the paper clips was designed to press against a strip of aluminum foil. Care, and some adjustments, had to be taken to get the correct angle on this triangle so that when it just pressed against the foil, the bottom of the clip was elevated a distance equal to the diameter of a mouse ball.
The other problem to overcome was the hinge. I first tried soldering the wires directly to the paper clips but this interfered too much with their ability to move. I rolled tubes out of foil around the clips and passed the wire leads through them. This allowed the clip to swing freely and kept an adequate electrical connection.
I taped the hinges down but found that the tape I was using did not hold nearly well enough. Sewing the hinges in place worked wonderfully and the unit has shown no signs of wear after a week of near constant use.
Currently the batteries are held in place with bent header pins. I have not yet figured out a more suitable enclosure for them. The current limiting resistor is soldered with the batteries. As only one LED should be lit at a time, only one resistor was required. The resistor was chosen to run the LEDs at half current. Brightness is not required but battery life is.
After the pipe was constructed I glued the magnet on the pipe. I found that the magnet was strong enough to attract the switches and keep a ball from rolling through the pipe. It was necessary to remove the bare magnet and glue it in place with the piece of metal that it was attached to in the hard drive. This made the magnetic field inside the tube negligible and had the added bonus of greatly increasing the magnet's holding force.
It was a simple project and took a couple hours but has already provided hours of brain-exercising entertainment for my kids. There's something hypnotizing about moving lights. It reminds me of KITT or cylons. I could watch this all day.