Project tutorial

Hot Wheels Car Photogate © GPL3+

Measure how fast your Hot Wheels car moves at different points on your track or use it to tell how fast your race was.

• 3,353 views
• 12 respects

Components and supplies

 Arduino UNO & Genuino UNO
×1
 Through Hole Resistor, 200 kohm
×1
 Through Hole Resistor, 2k ohm
×1
 High Brightness LED, White
×1
×1

Necessary tools and machines

 Soldering iron (generic)
 3D Printer (generic)

Students needed to measure how fast their Hot Wheels cars went along the track, so I built several inexpensive photogates to help them.

It uses a photo transistor to detect when the car passes and can calculate the speed of the car at whatever position you put the sensor holder. A white LED was used instead of an IR LED so it was more obvious the device was on and connected properly.

The 3D printing of the photogate is optional. During the proof-of-concept phase, the prototype of the sensor and LED holder was made from hot gluing cardboard pieces together, and it worked just fine, though not very durable.

One sensor can measure relative speed of one car (assuming a typical length car).

Two photogates can be used to be more precise, but the distance must be measured by the time seen in the Arduino serial monitor to make the calculations.

Below is an example of the single photogate and the serial output as the car passes.

Code

Single LED PhotogateArduino
Single photogate code for measuring of the speed of a single Hot Wheels car. The code allows the photogate to work in either direction.
```/* PhototransistorVoltage Hot Wheels Timer
* Power phototransistor with 5v and GND
* Connect the phototransistors yellow wire into A1
* Optional: Use a piezo buzzer connected to pin 4 and GND.
*/

const int buzzerPin = 4;  // other end of buzzer connected to GND
float threshold = 0.25;    // voltage where phototransistor shows car is in the way
const int interval = 5;  // accuracy of timer in milliseconds

void setup()                                 // Built-in initialization block
{
Serial.begin(9600);                        // Set data rate to 9600 bps
}

float v1, timerCount;
boolean waitFor2ndTrigger;

void loop() {
tone(buzzerPin, 440*6, 50);                   // Sound "ready"
timerCount = 0;
waitFor2ndTrigger = true;
v1 = volts(A1);                                // measure voltage from phototransister in A1
tone(buzzerPin, 880, 150);                     // Sound for start of waiting for trigger
Serial.println("Waiting for trigger...");      // wait for  phototransistor to be dimmed
while (v1 > threshold) {
delay(interval);                   // otherwise it's too fast to notice button press ((when one is used)
v1 = volts(A1);                    // measure voltage from phototransister in A1
}
Serial.print("Started...");                    // Display "Start"

while (waitFor2ndTrigger) {              // count time until phototransistor receives light again
delay(interval);                       // Delay for defined time
timerCount = timerCount+interval;      // Add time to counter
v1 = volts(A1);                        // check A1 phototransistor
waitFor2ndTrigger = (v1 < threshold);  // is "false" when phototransistor receives light again
}

// end timer count and display results
Serial.println("Stopped");             // Display " sec." & newline
tone(buzzerPin, 880, 50);              // Sound at finish
delay(80);
tone(buzzerPin, 880, 80);
Serial.print("Final Time = ");          // Display "Final Time = "
Serial.print(timerCount/1000);          // Display timerCount in #.### format instead of milliseconds
Serial.println(" seconds");             // Display " sec." & newline
Serial.print("Speed = ");               // Display "Speed = "
Serial.print(72/(timerCount/1000));     // Display speed based on 72 mm car
Serial.println(" mm/sec");              // Display "mm/sec" & newline
Serial.println("");                     // print blank line
delay(3000);                            // wait 3 seconds and reset
}

{                                            // Returns floating point voltage
}
```
Dual photogate codeArduino
Using two identical photogates to measure the speed of a Hot Wheels car going either direction. The code allows the photogates to work in either direction.
```/* PhototransistorVoltage Hot Wheels Timer
* Power each phototransistor with 5v and GND
* Connect the 2 phototransistors yellow wires
*       into A1 & A2 to detect start and stop of car.
* Use a piezo buzzer connected to pin 4 and GND.
*/

const int buzzerPin = 4;  // other end of buzzer connected to GND
float threshold = 0.25;    // voltage where phototransistor shows car is in the way
const int interval = 10;  // accuracy of timer in milliseconds

void setup()                                 // Built-in initialization block
{
Serial.begin(9600);                        // Set data rate to 9600 bps
}

float v1, v2, timerCount;
boolean v1trigger, waitFor2ndTrigger;
int count=0;

void loop() {
tone(buzzerPin, 440*6, 50);                   // Sound "ready"
timerCount = 0;
count = 0;
v1 = volts(A1);                      // measure voltage from phototransister in A1
v2 = volts(A2);                      // measure voltage from phototransister in A2
Serial.println("Waiting...");       // wait for either phototransistor to be dimmed
while (v1 > threshold && v2 > threshold) {
delay(interval);                   // otherwise it's too fast to notice button press
v1 = volts(A1);                    // measure voltage from phototransister in A1
v2 = volts(A2);                    // measure voltage from phototransister in A2
}
v1trigger = (v1 < threshold);  // find which was triggered
Serial.println("Start");                    // Display "Start"
tone(buzzerPin, 880, 150);                          // Sound for start of clock
v1 = volts(A1);
v2 = volts(A2);
waitFor2ndTrigger = true;                // check only A1 phototransistor

while (waitFor2ndTrigger) {              // count time until 2nd probe is triggered
delay(interval);                       // Delay for defined time
timerCount = timerCount+interval;
v1 = volts(A1);
v2 = volts(A2);
if (v1trigger) {
waitFor2ndTrigger = (v2 > threshold); // check A2 phototransistor
}
else {
waitFor2ndTrigger = (v1 > threshold); // check A1 phototransistor
}
}

// end timer count and display results
tone(buzzerPin, 880, 50);                   // Sound at finish
delay(80);
tone(buzzerPin, 880, 80);
Serial.print("Final Time = ");       // Display "v  Final Time = "
Serial.print(timerCount/1000);       // Display timerCount in #.### format
Serial.println(" sec.");             // Display " sec." & newline
Serial.println("");                  // print blank line
delay(3000);                         // wait 3 seconds and reset
}

{                                            // Returns floating point voltage
}
```

Custom parts and enclosures

Holder for photogate parts that sits under a standard flexible Hot Wheels track.

Schematics

Single photogate schematic
photogate1_J32ue6N6c6.fzz
Two photogates schematic
photogate2_YL7OCZuHcr.fzz

Author

nfarrier
• 3 projects
• 2 followers

• Reading the light level of a phototransistor by Parallax Inc

June 13, 2019

Members who respect this project

and 9 others

See similar projects
you might like

Race Photogate

Project tutorial by nfarrier

• 2,404 views
• 1 comment
• 4 respects

Turn your RC Car to Bluetooth RC car

Project tutorial by Prajjwal Nag

• 20,674 views
• 25 respects

Biometric Car Entry - True Keyless Car

Project showcase by Rajeev Velikkal

• 9,390 views
• 44 respects

RC Car Over Spektrum Remote

Project showcase by Gkid19

• 1,957 views
• 4 respects

RC Car to BT Car Controlled with Blynk

Project tutorial by Team Daxes Hacks

• 7,113 views