ARDUINO LAP COUNTER

Images

Lap Counter Close-up

Close up of the display showing the counts for four tracks. In this mode it counts up to 99, but when the lap counts hit 100 the display changes to an abbreviated version showing Ln1, Ln2, etc. for the top row (no "Lane") and just the lap counts for the bottom row (no "Laps").

Sensor board connections

The middle board is the one connecting the Arduino analog inputs to the reed switches underneath the track (the bottom board is the Arduino Uno). It is the protoshield board from Adafruit and comes with the pin headers allowing it to be stacked/sandwiched like this.

All Components

This is the full setup. I just use the USB power from an old phone USB charger and I made the cable connecting the sensors pad to the sensor board using some CAT5 cable I had lying around. I only needed five wires and it had more than that so I just clipped off the wires I didn't need. I put a connector in between allowing me to disconnect the track easily when I wanted to reprogram the Arduino. I use the Reset switch on the LCD shield to set the lap counters to zero.

Sensor pad

This sensor pad is just a sheet of computer paper cut to the size of the track and markings for the reed switches to go. The reed switches are taped (scotch tape) to the paper in the right spots - underneath one of the track rails, since the car magnets are intended to "stick" to them. Any wiring/solder connections are covered with tape as well.

Overview

This is a digital lap counter for pretty much any slot car track that uses cars with magnets built into their body. I am using an old Tomy AMX four-lane track and cars - the magnets help keep the cars on the track.

It is a pretty simple setup and the "hardest part" for me was soldering the connectors for the cable that I used to connect the Arduino boards to the sensor pad with all of the reed switches. I used an off-the-shelf LCD shield that uses the standard Arduino drivers, an Arduino Uno for the controller and a prototyping board from Adafruit that allows you to solder components and wires directly onto its surface which has all of the Arduino pins broken out. I have seen and used other boards like this one, and they would work for this as well. I just wanted a nice simple board that would plug-in between the LCD and the Arduino that would capture the circuitry necessary for hooking up the switches to the Arduino's analog ports.

Parts/Components Used
Velleman VMA203 LCD Shield

This is the shield I used but nothing is critical about it besides the price being under $10. It just uses the standard Arduino LCD library so no special drivers are needed.

Velleman VMA203 LCD Shield
Adafruit Proto Shield for Arduino Kit

This is the prototyping shield I like to use. It is from Adafruit and is under $10 so it is cheap. It comes unassembled so I just put the pieces on I needed (connectors) before soldering my pull-up resistors and wires for the sensor pad.

Protyping Shield
Reed Switch

The reed switch is probably the most critical piece of this project. I actually had a hard time finding these little jewels. The ones I found were at frys.com and were called Philmore Open Reed Switch. They have connections for normally open (NO) or normally closed (NC). I cut off the NC lead and just used the NO lead. There is really no reason to get this same switch, a standard normally open reed switch (with only two leads instead of three) will work just fine. There is virtually no current that flows through them so there is nothing to worry about regarding current rating. I used an ohmmeter to figure out which lead needed to be cut off (it was the longer of the two leads on the one side), the lead that needs to be used should show as an "open" when no magnet is used and "closed" when a magnet is used.

Philmore Open reed Switch
Sensors Schematic

The circuit is very simple. There are four pull-up resistors (10k in this case) that hold the Arduino analog pins A1-A4 at 5 volts normally. When the switches close (like when a car/magnet passes over the reed switch) the analog pin is taken down to ground level.

Lap counter diagram
Arduino Sketch

This sketch is setup for four tracks/switches and it shows lap counts up to 999. When the lap counts get over 99 then the display changes to a shorter/abbreviated display to allow all four tracks to have lap counts over 99 (three digits each).

It has some de-bounce logic as well so the car only produces a single lap count when going slowly over the track. It basically bumps the lap count when it first senses the pin going low and then ignores any other input on that pin for a brief time (800 milliseconds).

Since the display only needs to be updated when a lap count changes the display is only written to when any of the track counts change. This allows for fast processing and makes it very responsive. Between the de-bounce logic and this strategy for display updating the lap counts are extremely accurate (no counts are lost and nothing extra is given!).

LCDLapCounter.ino (Zip file)