This was a project that took a good bit of time, so I’ll split it up into multiple posts, just to keep each one a bit more manageable.
My father-in-law is involved with Scouting, and for that he bought a nice aluminum race track for the Pinewood Derby races that they hold every year. The track he got is VERY nice, and well it should be. He ended up paying over $900 for a 4 lane track! He also wanted a timer for the track, but as they wanted an additional $600-700 for the timer, he thought that maybe his electrical engineering son-in-law might be able to put something together for cheaper. I thought it sounded like a fun project and agreed to work on it.
Right upfront, I’ll say that the professional job looks better than mine as the final product. I could have spent more time on looks, but I was running short on time and he is also plenty capable as a carpenter (I built the structure out of a piece of fence wood) so I left it as-is, thinking he could touch it up if he wanted to.
I went on aliexpress.com and did a bunch of searching for parts. Even though there is quite a delay in waiting for parts to arrive from China with that website, the prices that you can get are phenomenal and pretty much impossible to beat. I ordered some mini Arduino clones, some 7 digit displays to show the time, and some LED matrices for showing animations as well as the larger place numbers. I liked the way that they had done their timer, so I had plans to emulate it to some extent. In addition to those larger things, I also ordered some interconnecting jumper wires, and a few different varieties of light sensors and infrared emitters and detectors. I could do experiments at home, but I didn’t have the track here so I picked up a variety so that I could go with whatever worked best once we were out there. (His house is an 8-hour drive from mine, so I waited until we were heading out there anyway to take all my parts and get it assembled.)
If you look at the track in the link above, you’ll see that there’s a lever up at the top end that is spring loaded and releases all of the cars at once. I decided to have a mechanical switch up at that end. In fact, the end-stop switches from 3D printers are super cheap and are already mounted on a circuit board, so that made it very easy to mount to the frame of the track. One thing that threw me for a bit when the code wasn’t working was that the switch on at least the ones that I got had 5V normally, and then went to 0V when the switch was pressed. I had assumed the opposite while programming, and at first I was looking at other possibilities for why it wasn’t working like I expected. There were a few coincidences and weird things going on that confused me enough that it took 5-10 minutes to realize what was going on. No problem once I switched it around so that what it expected matched what it actually got.
So the switch up at the top is activated by the same lever that starts the cars going down the track. Then the code just needs to keep track of the elapsed time until the different sensors ‘see’ a car crossing the finish line. After some experimentation, we settled on an IR sensor embedded in the track, so that the car going over it would block the light and trigger the timer to stop. We drilled holes in the track and put one sensor under each of the four lanes. Then using either ambient light or IR LEDs from above the code just needs to watch for a difference in the light level to know that the car is above. I’ll go into more detail in the code section. Finally, the microcontroller needs to keep track of which car finished in each place (first-fourth) as well as the time for that car. It should keep the final time for each car displayed until the reset button is pressed so that the record-keepers can note it down. The reset button is simply wired between ground and the reset pin of the Arduino, since no state needs to be kept between runs.
Overall a relatively simple project, but it ended up doing the job and costing less than 1/10th the cost of the professional one. (But that doesn’t count anything for my time. I was having fun with it, though.)