Project tutorial
Hot Wheels Car Photogate

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.

  • 8 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
4966285
Solder Wire, Lead Free
3drag
3D Printer (generic)

About this project

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
}
                                           
float volts(int adPin)                       // Measures volts at adPin
{                                            // Returns floating point voltage
 return float(analogRead(adPin)) * 5.0 / 1024.0;
}    
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
}
                                           
float volts(int adPin)                       // Measures volts at adPin
{                                            // Returns floating point voltage
 return float(analogRead(adPin)) * 5.0 / 1024.0;
}    

Custom parts and enclosures

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

Schematics

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

Comments

Author

Nfarrier
nfarrier
  • 1 project
  • 0 followers

Additional contributors

  • Reading the light level of a phototransistor by Parallax Inc

Published on

June 13, 2019

Members who respect this project

Goldrake 5zbyrwz02tSilicioslabSaulofilhoCac3dca5 93ff 46d4 9818 6dcc0bcbbf24

and 6 others

See similar projects
you might like

Similar projects you might like

Turn your RC Car to Bluetooth RC car

Project tutorial by Prajjwal Nag

  • 15,652 views
  • 2 comments
  • 18 respects

Biometric Car Entry - True Keyless Car

Project showcase by Rajeev Velikkal

  • 6,166 views
  • 6 comments
  • 38 respects

RC Car Over Spektrum Remote

Project showcase by Gkid19

  • 1,356 views
  • 0 comments
  • 1 respect

RC Car to BT Car Controlled with Blynk

Project tutorial by Team Daxes Hacks

  • 5,380 views
  • 2 comments
  • 7 respects

Remote Control Car w/ PocketBeagle and Arduino

Project tutorial by Christina Mezmur

  • 3,859 views
  • 3 comments
  • 13 respects

HVAC Car Control

Project showcase by hwhardsoft

  • 3,944 views
  • 1 comment
  • 20 respects
Add projectSign up / Login