This project is an Arduino (Atmega328) built on a breadboard, mounted on a Lego train. Connected to the Arduino is a time keeping DS1307 IC, an IR detector, and three super bright LEDs.
The electronics grab power from the Lego train it is on top of, and the train gets power from the electrified track it runs on. This is done by a bridge rectifier, and 7805 on the breadboard. The voltage of the track maxes out at a little over 9v, and can either be positive, or negative voltage based on the direction the train is set to move.
The bridge rectifier ensures that the 7805 always receives a positive voltage. The voltage to the track needs to be over 7v for the regulator to provide a stable 5v. A diode is connected from one of the rails to pin 12 of the Arduino. This causes pin 12 to be pulled low depending on the direction that the train is moving.
At 12 O’Clock on the track is an IR LED. As the train completes a lap around the track, the Arduino keeps track of how long it took to make the previous lap which it logs by sensing the IR LED.
Bumps in the track can throw off timing.
It uses the previous lap time to determine where to "draw" the Hour, Minute, and Second Hands.
HOURS are represented by the BLUE LED and is connected to Pin 10.
MINUTES are represented by the GREEN LED and is connected to Pin 9.
SECONDS are represented by the RED LED and is connected to Pin 6.
Different sets of drawing code is needed to place the time Clockwise, or Counter-Clockwise.