Introduction: Arduino Controlled Finish Line
Note: I've found some improvements since I wrote this: use an IR emitter/detector pair with a higher resistance on the detector (330K ohms instead of 56K ohms). Also, A "mini" arduino should work just fine -- the adafruit.com "Trinket" for example.
Features:
- First place displayed
- Ties displayed
- Automatic reset
- Easy operation and reading
- 20 microsecond accuracy
With some basic soldering skills and woodworking skills, you should be able to complete this build in only a few evenings.
Step 1: Materials and Tools Needed
Major Components:
1 - Arduino (any arduino compatible) -- Adafruit .com has a very inexpensive (about $8) mini-arduino called the "Trinket" that should work just fine (I haven't tried it yet). This design should work with 5 volt or 3 volt arduinos -- in some ways, 3 volts is better (less power)
2 - 56K 330K ohm resistors (1/4 watt) [I have found that IR photosensors need higher ohm resistors (for more sensitivity)]
2 - 330 ohm resistors (1/4 watt) (or 4, if using IR emitter leds).
2 - LEDs (red, green, blue, you choose!)
2 - IR Phototransistors (Radio Shack #276-0145) or Radio Shack #276-0142: Emitter & Detector pair (the emitter can be setup on a "bridge" pointing down at the detector, to make the detector work better.) If you do use the IR emitter leds, wire them up to your battery, or input power, with a 330 ohm resister in series (like on the red leds).
1 - 9 volt battery and adapter for arduino
Additional Materials:
- Wire
- Shrink tubing
- Small wood screws - 3/8 inch long (x6)
- Small washers (x8)
- 1/2 x 6 x 10 inch board used as a base (I used oak, but could be any wood)
- Self adhesive felt feet (x4)
- Cardboard / Poster board
- Packing tape
- Hot Wheels track and track connectors
Tools:
- Soldering Iron
- Wire cutters/strippers
- Drill and drill bits
- Screw driver
- Manual Staple gun
- Scissors
- Pencil
- Tape measure
Step 2: Source Code
// This is the arduino sketch: Open the arduino IDE,
// create a new file and copy/paste the following code into it.
// Don't forget to upload the code to your arduino!
/*
* Finish Line Detector
*
* Lights up LED 1 or 2 depending on which sensor is tripped first
* Both LEDs light up in the case of a tie
*
* Accuracy:
* As there are only a few lines of code in the loop
* (actually more instructions after it gets compiled) and considering
* that the arduino runs at 16Mhz (million cycles per second),
* we have an accuracy much better than a millisecond.
* With an oscilloscope, I determined that the code actually takes about
* 20 microseconds to execute. Should be good enough.
*
* Author: Ted Meyers - February 2, 2011
*/
const int ledPin1 = 12;
const int ledPin2 = 13;
const int sensorPin1 = 2;
const int sensorPin2 = 3;
const int TIMEOUT = 3000; // milliseconds
// Setup runs once, at start
// Input and Output pins are set
void setup(){
pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
// Called repeatedly
void loop() {
// Get the Sensor status
int status1 = digitalRead(sensorPin1);
int status2 = digitalRead(sensorPin2);
// Set the output LED to match the sensor
digitalWrite(ledPin1, status1);
digitalWrite(ledPin2, status2);
if (status1 == HIGH || status2 == HIGH) {
// A sensor was tripped, show the results until timeout
delay(TIMEOUT); // Wait for timeout
}
}
Step 3: Build the Base
You will want to start with a board about 1/2 x 6 x 10 inches; the dimensions don't have to be exact. Cut the board to size if needed.
Make a line about 1.5 inches parallel to the long end for placing the holes for the 2 sensors and 2 LEDs. For the track I used, the sensors need to be 1.75 inches apart, mark these positions. Next mark the positions for the LEDs about 1.25 inches out from the sensors. Next draw the center lines for the two track lanes going through the sensor marks and perpendicular to the long side of the board. These lines will be used when mounting the track connector piece. While not necessary, I also marked lines to show where the track is placed.
The last hole is for the wires to go through to the bottom of the board. It's placement is not critical, just as long as it is not in the way.
Drill the holes. For the sensors, drill a 1/4 inch hole about half way though the bottom, and a 5/32 inch hole the rest of the way (this keeps the sensor from going all the way through from the bottom to the top, and also lets less light come in from the side). For the other 3 holes, drill a 1/4 inch hole all the way through (if you want, drill a larger hole for the wires, it will make it easier to push them through later on).
Step 4: Schematic
Note: I've found that a higher resistance makes the IR sensors more sensitive, I am now recommending 330K ohm resistors here.
It's a fairly simple circuit, I did not use a circuit board, just soldered the sensors/LEDs to wires along with the resistors and soldered the wires together as shown. Start by soldering long wires to the sensors and LEDs. Now solder in the resistors and the rest of the wires (power, ground, signals). Just make sure the wires are all long enough. Next place the LEDs/sensors in the mounting holes in the bottom of the base built in the previous step, and push the wires through the wiring hole to the top.
Finally, plug the wires into the appropriate pins on the arduino, and test it out. (You may have to almost completely cover the sensors to block enough light to trigger them.
Step 5: Mount Components to Base
Put the LEDs and sensors in their holes in the base (underneath). Bend the wires flat to the base and staple in place. Be careful not to put a staple through any wires. Push the wires through the hole to the topside of the base.
Turn the base over and staple the wires in place on the top.
Finally, plug the wires into the arduino and test.
Step 6: Finishing Up
Stick on felt feet to the corners of the bottom of the base.
Cut a piece of cardboard or poster board to cover the wiring and tape it in place to bottom of base.
Turn the base right side up and use the center lines marked in step 3 to position the 2 track connectors and make marks for the screw holes using the existing holes in the connectors. Drill the holes for the screws (using a drill bit slightly smaller than the screws).
Screw the track connectors in place, putting two small washers between the base and track connector under each screw (for spacing).
Use 2 of the mounting holes in the arduino to make marks on the base for screw holes. Drill the two holes (again with a smaller drill bit than the wood screws). Finally screw the arduino to the base.
Attach some hot wheels track to the connectors on the base and you are done!
Step 7: Usage
Try to set up the track so that both lanes are at an equal height and slope.
After each race, the timer will display the results for 3 seconds and then automatically reset.
When you get tired of racing, try modifying it to send the difference in time between the two lanes to the computer over the serial port. Another fun modification would be to use the two sensors to calculate the speed of one car. Good Luck!
Hope you have as much fun as we did!

Participated in the
Microcontroller Contest
41 Comments
Question 2 years ago
Hi Ted, Back in 2007 I built a six-lane 72' long undulating race track for racing AUSTIN HEALEY Hotwheels cars for a national event attended by over 400 registrants. (see photos) Throughout the five day event we ran elimination heats, quarter finals, semi-finals etc, advancing 3 or 2 of the fastest cars to the next round. I see that Hotwheels now has a six-lane finish line that indicates which position, 1-6 the cars finish. We are running this same event for 2022 in for the Austin Healey Club of America and I really want to enhance our last track, which has been in dry storage for 14 years. I need to HIRE someone who can build this simple circuit for me using light sensors which I can add to the track. We DO NOT need timing, JUST 1-6 finishing indicators with a reset for each racing heat, of which there will be about 100 heats. Please contact me, I will supply all electronic materials necessary. I would like the unit to be compact and connectors can be mini plugs or jacks. PLEASE CONTACT me ASAP, Steve Bell scbell1@comcast.net
Question 4 years ago on Introduction
Hi Ted, I did your project, but I used 4 lanes. I like the result, but now I want to use segment 7 displays. Do you think it´s possible? Or will I have problems with the lack of Arduino ports?
Thank you very much Ted, for your help!
Reply 4 years ago
Hey, nice looking finish line!
For the display, you might try something like this: https://www.sparkfun.com/products/11442
It is a 7 segment display with TTL, SPI or I2C Serial Interface -- making it very easy to control with only a few I/O pins.
Reply 4 years ago
Thank you for attention Ted. I´ll try and then I post the result! TKS!
4 years ago
I want to make this for my son is there a copy and past code someone has done for 4 lane that works I am not the best with computers or really know what to do I can handle the wiring and putting it all together just looking for some help with the coding
Question 4 years ago on Step 3
Hi Ted, can I use the LDR instead of the phototransistor?
TKS
Reply 4 years ago
Yeah, but LDRs are a lot slower to respond than phototransistors, so it won't be as accurate. Also, you will probably have to change the circuit (I haven't looked at the circuit in a while, so I'd have to look at it again to figure out how). I think that you'd set up the LDR like a potentiometer (make a voltage divider) and measure it on an analog input pin -- lots of arduino examples for this (pots and/or LDRs).
Reply 4 years ago
Cool tks Ted!
Question 4 years ago
Hi Ted, can you tell me the TIL 78 phototransistor? Thank you!
Reply 4 years ago
Probably, I'm not familiar with a TIL 78, but there are a lot of phototransistors out there that will work as long as you wire them up properly. You might have to change the resistor values a bit.
Question 4 years ago
Hi, thanks for sharing his project. Had you made an updated version of this? I’m just beginning with arduino and would like to make this for my 2 year son with a display that show the winner, and like somebody say, a led counter before the race and an automated launcher. I’ll be making this project soon. Thanks and greetings from Mexico.
4 years ago
hi,im working on this thanks for sharing!
i have some question...
1.sorry i messed up is it 330k ohm or 330 ohm?
2.the photosensor wiring the long feet or the short one on to the ground?
i will put in on youtube and credits to you after the project is done!
keep sharing!
Reply 4 years ago
Hi its me again
Finally i made this!
And "unluckily" i forgot to powered it off after using for couple of hours and the 9v battery is drained out,i do search some arduino power consumption and how to reduce it,is it okay if i add/use Power Sleep Mode instead Active Mode?,the code written like this
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
Does it affect the function?
I will post everything after the beta version is done,thanks for all contribution!
Reply 4 years ago
Don't know how low-power mode will affect the code, probably depends on where you put it. (I've never tried low-power). Maybe have a check for no activity for a while? Also, you could add a 5V wall power plug to the arduino (instead of battery).
Reply 4 years ago
Thanks for reply!
Okay thing gets clearer,i didnt use the radioshack because is not available at my country,so i use photoresistor the black glass,looks like the pic that i attach here it says ir receiver 940nm,or can i use this kind of sensor? (picture 2)
ps. I have an idea maybe you can make a starting gate with red green yellow start gate with sound like in circuit race :p
Reply 4 years ago
The sensor that I used is actually a phototransister. The first picture that you show looks a lot like a phototransistor. The second picture is a photo-resistor, which is much different. You could make it work, but you'd have to change the circuit. Also, photo-resistors are quite slow to react to a change in light; several tens of millisecond, while the phototransistor only takes a few microseconds. So, you timer would not be very accurate if you used a photo-resistor.
Yes! You could add a starting gate with colored lights, and even sounds. That would be cool!
Reply 4 years ago
Okay i will not use the photoresistor,just for make sure,so the black glass phototransistor is okay to replacing the radioshack sensor that you use?, and the others part is same as the schematic.
I'm sorry im just try to figure it all in the right place i'm halfway trough this.
Reply 4 years ago
It is hard to tell without looking at the specifics of the components you are trying to use. I believe that 940nm is okay (that is in the infrared spectrum and there was enough ambient infrared when I tested my sensor to get it to work (a room with incandescent bulbs -- or outdoor light works great). Other than that, I really don't know anything about your sensor. You might have to adjust the sensor resistor to get the sensitivity correct. A potentiometer with the right range (0 - a few hundred K ohms is good) works well for this. It is best to just temporarily wire things up to test it. you can always unsolder/cut the wires and resolder if you are careful.
Reply 4 years ago
330K ohms for the sensor resistor. Usually the ground (cathode) is the shorter wire, but it would be best to look at the datasheet for the particular sensor you have (if you can find it). You can also temporarily wire the components together (breadboard, alligator clips, paper clips, whatever) and see which way works. You shouldn't be able to break it, even if you get it backwards -- at least not a photosensor.
6 years ago
Looks like a great project and I'm giving it my best. However, every time I try and load the sketch to my Arduino uno or my nano I get the same response. An error msg. I can load the basic sample sketches like BLINK etc. whithout any problems. I can copy&paste the error msg here if that will help.