Toy Car Speed Timer. Created by Kirby Griese. Last updated on :13:49 PM UTC

Similar documents
Adafruit Capacitive Touch Sensor Breakouts

Guardian Shield+ Zelda Breath of the Wild

Audio Prank Gift Box. Created by Becky Stern. Last updated on :46:15 PM UTC

Trinket-Powered Conference Room Occupancy Display

Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

Adafruit APDS9960 breakout

Adafruit 8x16 LED Matrix FeatherWing

Adafruit AMG8833 8x8 Thermal Camera Sensor

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

7 Portable Multitouch Raspberry Pi Tablet

Adafruit TPL5110 Power Timer Breakout

Monochrome OLED Breakouts

Solar Boost Bag. Created by Becky Stern. Last updated on :44:55 PM UTC

Coffee Detonator: The TNT Plunger Grinder

Joy Featherwing. Created by Dean Miller. Last updated on :03:07 PM UTC

Feather Weather Lamp. Created by Ruiz Brothers. Last updated on :54:26 PM UTC

Adafruit 1.27" and 1.5" Color OLED Breakout Board

Trellis 3D Printed Enclosure

FeatherWing Proto and Doubler

Adafruit I2C FRAM Breakout

Mad Science Test Tube Rack

Adafruit IO Basics: Temperature & Humidity

Adafruit TPL5111 Reset Enable Timer Breakout

Adafruit PowerBoost 500 Shield

FeatherWing Proto, Doubler and Tripler

7" Portable HDMI Monitor

FLORA TV-B-Gone. Created by Becky Stern. Last updated on :32:57 PM UTC

Adafruit Si5351 Clock Generator Breakout

3D Printed Camera LED Ring

Neon LED Signs. Created by John Park. Last updated on :11:09 PM UTC

3D Printed Case for Adafruit Feather

Interior Purse Light. Created by Becky Stern. Last updated on :41:08 PM UTC

FPV Mini Display. Created by Ruiz Brothers. Last updated on :00:18 PM UTC

Trinket NeoPixel LED Longboard

Adafruit LED Sequins. Created by Becky Stern. Last updated on :02:00 AM UTC

i2c/spi LCD Backpack Created by lady ada Last updated on :11:04 PM UTC

NeoPixel Bike Light. Created by Ruiz Brothers. Last updated on :43:46 PM UTC

OLED 2864 Display module (SKU:TOY0007)

Adafruit HUZZAH32 - ESP32 Feather

3D Printed Google AIY Voice Kit

Adafruit Color Sensors

Clockwork Goggles. Created by John Park. Last updated on :03:10 PM UTC

Adafruit DRV2605 Haptic Controller Breakout

3D Printed LED Knuckle Jewelry

Adafruit AS channel Visible Light Sensor

NeoPixel Ring Bangle Bracelet

IS31FL x9 Charlieplexed PWM LED Driver

Light-Up Angler Fish Embroidery

Bike Wheel POV Display

PyPortal View Master Created by Ruiz Brothers. Last updated on :51:28 AM UTC

Portable Apple Watch Charger

LED Eyes. Created by Ruiz Brothers. Last updated on :50:55 AM UTC

TSL2561 Luminosity Sensor

Adafruit CCS811 Air Quality Sensor

GPS Dog Collar. Created by Becky Stern. Last updated on :30:40 PM UTC

NeoMatrix 8x8 Word Clock

Adafruit PCF8523 Real Time Clock

Celebration Spectacles

NeoPixel Basketball Hoop

Cup o' Sound. Created by Becky Stern. Last updated on :30:06 PM EST

Mystical LED Halloween Hood

Lie Ren's Stormflower Gun Blade

Adafruit Prototyping Pi Plate. Created by Ladyada

Interactive Gift Box. Created by codingpro. Last updated on :47:40 AM UTC

Adafruit DRV2605 Haptic Controller Breakout

MP3 Feather - Gordon Cole

3D Printed 20w Amplifier Box

MCP Bit DAC Tutorial

Infinity Mirror Valentine's Candy Box

Adafruit Si7021 Temperature + Humidity Sensor

Bluetooth Controlled NeoPixel Headphones

Adafruit LED Sequins. Created by Becky Stern. Last updated on :00:06 PM EST

Data Logging with Feather and CircuitPython

NeoPixel LED Cortana Costume

FLORA Pixel Brooch. Created by Becky Stern. Last updated on :19:07 PM EST

'Sup Brows. Created by Kate Hartman. Last updated on :52:04 PM UTC

Bunny Ears with MakeCode

Flora Brake Light Backpack

Boomy The Boombox. Created by Ruiz Brothers. Last updated on :52:13 PM UTC

Circuit Playground Digital Input

Adafruit MMA8451 Accelerometer Breakout

Chirping Plush Owl Toy

Adafruit IO Basics: Analog Input

3D Printed 20w Amplifier Box

Adafruit Mini TFT " 160x80

MLX90393 Wide-Range 3-Axis Magnetometer

DIY Bluetooth Gamepad

0.96" mini Color OLED

Lady Ada's Bento Box. Created by lady ada. Last updated on :55:35 AM UTC

Mystery Box: Haunted Radio

Adafruit 8x16 LED Matrix FeatherWing

NeoPixie Dust Bag with Circuit Playground Express

Magical Mistletoe. Created by Leslie Birch. Last updated on :45:29 PM UTC

1.8" TFT Display Breakout and Shield

CircuitPython Media Dial

FLORA and GEMMA ICSP. Created by Becky Stern. Last updated on :42:16 PM UTC

Adafruit SGP30 TVOC/eCO2 Gas Sensor

Adafruit ATWINC1500 WiFi Breakout

Adafruit MMA8451 Accelerometer Breakout

Circuit Playground Express Head-Tilt Ears

Transcription:

Toy Car Speed Timer Created by Kirby Griese Last updated on 2017-03-20 09:13:49 PM UTC

Guide Contents Guide Contents Overview Parts needed Prerequisites 3D Printing Assembly Wiring Software Use It 2 3 3 4 5 7 11 16 19 Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 2 of 21

Overview I like collecting 1/64 scale cars and was wondering how fast they are on my track. Using two IR Break Beam Sensors I can measure the time between both sensors being triggered and determine the speed. I can then also see if a heavier car is faster and if rubber wheels are better than plastic. Parts needed The following parts were used to build this Feather M0 Basic Proto (http://adafru.it/2772) FeatherWing OLED (http://adafru.it/2900) Feather Header Kit (http://adafru.it/2886) 2x IR Break Beam Sensor 3mm (http://adafru.it/2167) Breadboard-friendly SPDT Slide Switch (http://adafru.it/805) Lithium-Ion Polymer Battery (optional) (http://adafru.it/drl) Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 3 of 21

4x 4-40 3/8" Machine Screws 4x 2-56 3/8" Flat Head Machine Screws The Feather M0 can also be substituted with a Feather 32u4 Basic proto (http://adafru.it/2771) Prerequisites The following two guides should be followed to make sure the necessary drivers and libraries are installed in the Arduino IDE. The guides also show how to solder the headers on. Adafruit Feather M0 Basic Proto (http://adafru.it/vac) Adafruit OLED FeatherWing (http://adafru.it/vad) If you havent soldered before this is a great guide to learn how to solder. Adafruit Guide To Excellent Soldering (http://adafru.it/dri) Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 4 of 21

3D Printing Most of the parts are designed to be printed without supports. The top part is only part that well need supports in the sections the sensors go in. I have the required supports shown in green. The largest part is 68mm x 45mm and 135mm Tall Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 5 of 21

The STL files are available below along with the Fusion 360 design files if you would like to adjust any of the dimensions. Speed Timer - STL's http://adafru.it/vae Speed Timer - Fusion 360 http://adafru.it/van Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 6 of 21

Assembly Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 7 of 21

Insert the sensor with 3 wires in the base with the wires routed to the center. Then screw it down using the a 2-56 3/8" Flat Head Machine Screw. Repeat this for the left side also. Similiar to the last step we now will insert the transmitters in the top. These each have two wires. Then screw down with 2-56 3/8" Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 8 of 21

Flat Head Machine Screw to secure them in. Now that the sensors are installed we will put the two pieces together. Make sure the sensors are all secured before this since after it will be hard to reach the screws to tighten them down. Move the wires to the side and slide the two parts together. This might require some light sanding of the parts depending on how well it printed. Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 9 of 21

Now we can route the wires through the hole and continue to next step of wiring. Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 10 of 21

Wiring We should now have the Feather M0 and Featherwing OLED assembled and the headers soldered on each Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 11 of 21

The Fritzing diagram shows where to connect the wires. For power we will be using the 3.3v connections on the proto section. The ground will be connected the GND connections on the proto also. The transmitters just need power and ground. For the receivers they will also need a signal wire. For Sensor 1 we will use pin 10, Sensor 2 will use pin 11. Those will be wired to the space provided on the OLED FeatherWing. Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 12 of 21

To get the correct lengths for the cabling we will temporarily put one 4-40 3/8" Machine Screw in to hold the OLED Featherwing and Feather. Then use tape to temporarily hold the wires in approximate position to cut them to a shorter length. For wiring up the on/off switch we will reuse some of the wire that was cut off in the previous step. Verify that you have enough length to go from side of case with cutout for the switch to the GND and EN pins on the OLED FeatherWing. The switch has 3 pins, but we Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 13 of 21

only need the middle and one of the outer pins. The other unused outer pin can be left on or trimmed off. Once the wires are soldered to the switch insert in to the opening on the right side. As mentioned previously we will wire the signal wires from the sensors to the OLED FeatherWing. There is a row on each side available for soldering connections. Sensor 1 is the one on the right of the track and will connect to pin 10. Have the wire come from under the board so it will not interfere with screwing the display to the 3D printed parts. Then wire Sensor 2 to pin 11. The slide switch will wire to the EN and GND on the OLED FeatherWing. Polarity for this does not matter. The power and ground will be soldered to the rows provided on the proto section of the Feather Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 14 of 21

board. We will have those wires come from the top of the board. Now attach the OLED FeatherWing to the Feather board and it should look like the image above. Next using 4x 4-40 3/8" Machine Screws attach the boards to the assembly. To prevent the reset button from being pressed in, do not fully tighten the screws. Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 15 of 21

Software The program will start counting in milliseconds when the beam for Sensor 1 is broken and then stop when beam for Sensor 2 is broken. It will then calculate the speed to miles per hour. The distance between the two sensors is 106mm. The formula for Millimeter per second to Miles per hour is 1mm/s = 0.0022mph. Since the program returns the value in milliseconds instead of seconds it was easier to move the decimal in the distance from 106 to 106000 rather than convert milliseconds to seconds. If you change the distance between the sensors you will need to change that value. // convert mm/s to mph mph = ((106000 / elapsed_time) * 0.0022); The code is also designed that once Sensor 1 is triggered it will not trigger again until Sensor 2 is triggered. Sensor 2 can not be triggered if Sensor 1 is not triggered. So when using the timer always have the car to be timed enter from the right side. Below is the full code to load on to the Feather #include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> Adafruit_SSD1306 display = Adafruit_SSD1306(); #define SENSORPIN1 10 //Sensor 1 is on the right #define SENSORPIN2 11 //Sensor 2 is on the left long end_time; // When Sensor 2 is triggered long start_time; // When Sensor 1 is triggered long elapsed_time; // End time minus start time float mph; // Speed calculated int trigger1 = 0; // Sensor 1 int trigger2 = 0; // Sensor 2 int sensor1state; // Sensor 1 status int sensor2state; // Sensor 2 status void setup() { pinmode(sensorpin1, INPUT); // Sensor 1 as input Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 16 of 21

digitalwrite(sensorpin1, HIGH); // Turn on the pullup pinmode(sensorpin2, INPUT); // Sensor 2 s input digitalwrite(sensorpin2, HIGH); // Turn on the pullup // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) display.begin(ssd1306_switchcapvcc, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) // Clear the buffer. display.cleardisplay(); display.display(); display.settextcolor(white); } // Function to determine speed void speed() { // subtract end time from start time to get total time elapsed_time = ((end_time - start_time)); // convert mm/s to mph mph = ((106000 / elapsed_time) * 0.0022); // set OLED display text size display.settextsize(3); // Clear the buffer. display.cleardisplay(); display.display(); display.setcursor(0, 0); display.print(mph); display.settextsize(2); display.print("mph"); display.setcursor(0, 0); display.display(); // actually display all of the above } void loop() { // Read the state of the IR sensor 1: sensor1state = digitalread(sensorpin1); // See if IR beam of sensor 1 has been broken if (sensor1state == LOW) { // Check to make sure both sensors have not triggered if (trigger1 == 0 && trigger2 == 0) { // Save time when sensor 1 was triggered Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 17 of 21

start_time = millis(); // Prevent sensor 1 from triggering again trigger1 = 1; } } // Read the state of the IR sensor 2: sensor2state = digitalread(sensorpin2); // See if IR beam of sensor 2 has been broken if (sensor2state == LOW) { // Check to make sure sensor 1 has triggered but not sensor2 if (trigger2 == 0 && trigger1 == 1) { // Save time when sensor 2 was triggered end_time = millis(); // Run speed function speed(); // Prevent sensor 2 from triggering again trigger2 = 1; } delay(1000); // Reset both sensors trigger1 = 0; trigger2 = 0; } } Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 18 of 21

Use It You can use the timer by powering the Feather through USB or using a Lithium Ion battery. Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 19 of 21

Once the car goes past both sensors the speed will be displayed. I did not have another track piece to connect to the left side. But both sides are compatible with Hot Wheels tracks. If nothing is displaying verify that the display is not too tight to the enclosure causing the reset button to be held in. Adafruit Industries https://learn.adafruit.com/toy-car-speed-timer Page 20 of 21

I designed the timer to fit taller vehicles but some are too wide for the track and will not fit. This vehicle was an example, it was just a bit too wide. Adafruit Industries Last Updated: 2017-03-20 09:13:48 PM UTC Page 21 of 21