Description
This is a cheap and simple finish line judge for a two-lane pinewood derby track.
Photovoltaic sensors are installed into holes drilled into the center of each lane, and a light or LED is placed directly overhead of each sensor. Once a car's shadow passes over one of the sensors (causing the sensed light to dim by 50%), that car will be declared the winner.
The following enhancements have been made to the previous version of this project:
- A pixel array now points to the left (lane 0) or right (lane 1) to indicate the winner.
- A built-in speaker plays fun tones at various points in the race.
- Button A now triggers a servo, which can be wired to the starting gate to remotely start the race. The servo resets at the end of the race.
- The race time of the winner is recorded and output over serial, but there is no other way to see the race time in this version.
This project was done using MakeCode to demonstrate to Cub Scouts that electronics can be useful and FUN!
Code Readability Enhancements
Two changes were made to make the code easier to read for new programmers.
- Lanes have been renumbered to "0" and "1" (instead of "1" and "2") for consistency.
- Most code was consolidated into the start up function, since the program has a definite beginning and end.
Circuit Playground Express
This project uses the Circuit Playground Express because of the built-in pixel ring and its popularity as a beginner development board.
AdaFruit has a good overview published on their website, including instructions for driver install and sample programs.
Board Pinout
Use this extension
This repository can be added as an extension in MakeCode.
- open https://maker.makecode.com/
- click on New Project
- click on Extensions under the gearwheel menu
- search for the URL of this repository and import
Edit this extension
To edit this repository in MakeCode.
- open https://maker.makecode.com/
- click on Import then click on Import URL
- paste the repository URL and click import
Blocks preview
This section shows the blocks code from the last commit in master.
Wiring Preview and Pixel Status
This section shows generated wiring previews and pixel statuses at various stages of the race.
Calibrating
The board is calibrating the photovoltaic sensors to determine are reasonable "low" level. Car presense will be indicated when the light level drops to 50% of this detected level.
Ready
This status indicates that the user may press button A at any time to begin the race.
Launched
This status indicates that the servo has dropped the gate and the cars are now in motion. The board is now looping, waiting for a shadow to pass over the photovoltaic sensors.
Lane 0 Win
When lane 0 is the winner, pixels point to the left.
Lane 1 Win
When lane 1 is the winner, pixels point to the right.
Adding a Lane
A lane can be added by editing two functions in the block editor. Review the following function:
function lightSensorRead
set lightSensorCurrent to
(array of
(analog read pin A2)
(analog read pin A3))
Change it to:
function lightSensorRead
set lightSensorCurrent to
(array of
(analog read pin A2)
(analog read pin A3)
(analog read pin A4))
The function pixelShowWinner will also need to be modified to display a unique pixel pattern to indicate the winning lane.
Supported targets
- for PXT/maker
- for PXT/codal (The metadata above is needed for package search.)