Hot wheels speed sensor

I built a Hot Wheels toy car track speed sensor using Arduino and metal detector.

The main processing unit is Arduino Uno + sensor shield on top of it.  The display is cheap LCD display that connects to I2C. The sensor is metal detector kit I tested and converted to Arduino sensor in Metal detector kit converted to Arduino sensor article.

Here is closeup to the circuit

Theory of operation. The sensor connected to digital pin 12 is normally low. When a toy char is detected, it turns to one. The software measured the length of logic 1 pulse to detect the car speed (how long it takes to pass the sensor). The information that card has been detected is printed to the small LCD screen and sent to Arduino serial port (so can be logged on PC if needed).

Here is the Arduino code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3f,16,2); // set the LCD address to 0×20 for a 16 chars and 2 line display

int sensorPin=12;
int pinState=0;
int oldState=0;
int carTime=0;
int carSpeed=0;
int trig;
int pulselen;

void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
Serial.begin(9600);
pinMode(sensorPin, INPUT);
lcd.clear();
lcd.print(“Hello, world!”);
}

void lcd_print(String line)
{
int index=0;
while (index < line.length())
{
lcd.write(line.charAt(index));
index++;
}
}

void show_screen(String line1, String line2)
{
Serial.println(line1);
Serial.println(line2);
lcd.clear();
lcd.setCursor(0, 0);
lcd_print(line1);
lcd.setCursor(0, 1);
lcd_print(line2);
}

void loop()
{
pinState=digitalRead(sensorPin);

if (pinState != oldState)
{
if (pinState == 1)
{
trig = millis();
lcd.clear();
lcd.setCursor(0, 1);
show_screen(String(“Auto paikalla”), String(“”));
}
else {
// clear the screen
lcd.clear();
pulselen=millis()-trig;
carTime=pulselen;
if (carTime > 0) {
carSpeed=1000/carTime;
}
else carSpeed=0;
show_screen(String(“Aika ” + String(carTime,DEC)),
String(“Nopeus ” + String(carSpeed,DEC)));
}
oldState=pinState;
}
}
void oldloop()
{
// when characters arrive over the serial port…
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}

5 Comments

  1. Tomi Engdahl says:

    Another project with similar aim:
    Arduino Hot Wheels Speed Track Part #2 – Code © GPL3+
    https://create.arduino.cc/projecthub/unexpectedmaker/arduino-hot-wheels-speed-track-part-2-code-ade577?ref=user&ref_id=328294&offset=0

    An Arduino and Bluetooth-based Hot Wheels finish line timer to record cars’ speed and determine the winner of each heat.

    Reply
  2. Tomi Engdahl says:

    Speeduino – Speed Tracker © GPL3+
    Get the speed of your die-cast toy car!
    https://create.arduino.cc/projecthub/NerdFatherRJ/speeduino-speed-tracker-c8fcae

    Get the speed of toy die-cast cars!

    We, kids of all ages, enjoy playing with our fancy cars… We NEED to know how fast they run.

    Reply
  3. Tomi Engdahl says:

    Hot Wheels Car Photogate © GPL3+
    https://create.arduino.cc/projecthub/nfarrier/hot-wheels-car-photogate-bcff00

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

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

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

    Reply
  4. Tomi Engdahl says:

    This race timer will let you know which Hot Wheels car crossed the finish line first — along with its speed.

    Race Start Timer and Speed Measure for Hot Wheel Model Cars © LGPL
    https://create.arduino.cc/projecthub/cooksprojects/race-start-timer-and-speed-measure-for-hot-wheel-model-cars-6c0f0b

    Start sequence then find race winner of Hot Wheels type cars. Displays total race time, both car speeds and winning difference in time.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*