Arduino Controlled Finish Line




Microcontrollers are great at blinking LEDs and reading sensors.  With that in mind, I built this simple electronic finish line so that my 5 year-old son could easily see which of his hot wheels finished first.

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 "Trinket" for example.

   - 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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

- 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

The track works best when directly under an infrared light source.  Any incandescent light will do just fine.  If the finish line triggers on it's own, you will need to reposition your light and/or finish line, or get a brighter light.

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!

Microcontroller Contest

Participated in the
Microcontroller Contest

1 Person Made This Project!


  • Assistive Tech Contest

    Assistive Tech Contest
  • Reuse Contest

    Reuse Contest
  • Made with Math Contest

    Made with Math Contest

40 Discussions


Question 9 months 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!

2 answers

Reply 9 months ago

Hey, nice looking finish line!

For the display, you might try something like this:
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 9 months ago

Thank you for attention Ted. I´ll try and then I post the result! TKS!


11 months 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


Reply 1 year 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).


Question 1 year ago

Hi Ted, can you tell me the TIL 78 phototransistor? Thank you!

1 answer

Reply 1 year 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 1 year 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.

Hot WheelsA

1 year 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!

7 replies
Hot WheelsAHot WheelsA

Reply 1 year 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!

TedMeyersHot WheelsA

Reply 1 year 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).

Hot WheelsAHot WheelsA

Reply 1 year 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

IRReceiverF5940nm940_1.jpg.jpgimages (16).jpeg
TedMeyersHot WheelsA

Reply 1 year 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!

Hot WheelsATedMeyers

Reply 1 year 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.

TedMeyersHot WheelsA

Reply 1 year 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.

TedMeyersHot WheelsA

Reply 1 year 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.


2 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.

1 reply

Reply 2 years ago

Yes, send me the error message. Could be that the newer Arduino versions aren't compatible with this old sketch. I'm good at debugging this type of problem.