The two LDR sensors are illuminated by LEDs placed in front of the sensor. The ball passes in front of the first sensor and starts the timer.

When the ball passes in front of the second sensor the timer is stopped and the speed is calculated.

A button allows you to reset the counter and measure another throw.

  • Focus for students on light measurement.
  • Focus on finite state machine in coding.
  • Focus on button behaviour.

Last, I've added a seven segments display and build a movable-stable object to easy play in the classroom.


The tube

The tube is equipped with the two sensors, two holes were made to apply the lights on a side and the sensors in front of the lights. Hot glue to keep the parts in place and pay attention: LED and LDR should not touch the ball when it passes through the tube.

Physic

The physic of this project is simple:

  • D = distance
  • S = speed
  • T = time

So:

So the code should read the first LDR to find the exact moment when the ball covers the sensor and starts the timer. When the ball passes and covers the second LDR sensor the counter is stopped. We have found T.

The total distance run by the ball is 1 meter (the length of the tube) and so we can calculate S, the speed.

Finite state machine

When the program describes the behaviour of a system we talk about "finite state machine", that is a system which has some defined known statuses and can pass from a status to another when some specific action happen.

We start from status 0:

  • 0 = ready to start, the counter is zero, the LDRs are lightened
  • 1 = the ball has been thrown and has passed the first LDR sensor, the counter starts
  • 2 = the ball has passed the second LDR sensor, the timer is stopped
  • 3 = the calculus of the speed is done and the resulting speed is shown

The code, essentially, measures sensors and check conditions to detect when the status need to be changed.

Code available here:

https://github.com/giuliopons/arduino-marble-speed-game

Make it portable

While playing the game the tube is hurted, cables move, contacts fail, so I've decided to assembly a complete portable version of the project to play in the classroom with the students! Coding for the display not included in the lessons, there isn't enough time!

The complete project is something like this: 

I hope to add soon a complete wiring diagram.

Video

 A small video with a throw at 317 cm/sec (7 mph):