This is the ending line gate for a line following race track. The gate receives a signal to start two timers once both cars have left the starting gate and the timers are halted by breaking two corresponding tripwires at the end gate.

Dependencies:   mbed

About

This is a program that is used in determining the race times of two separate line following cars on a track. The program uses a wireless signal that is sent from the starting gate to determine when to start the timers and the timers are stopped by breaking the tripwire at the finish line. The first race car to break a tripwire will have that corresponding gate's LED lights also light up to indicate which car finished first. This is achieved almost entirely through interrupts in which a falling condition is detected for the tripwires and a rising condition is detected for the timer start. The times can also be printed out to a terminal screen by pressing a connected button. Alternatively, the ending gate can work entirely without timing by disregarding the receiving component.

Hardware

The hardware to implement this is fairly straightforward and is shown below. The G and B indicate different colored LEDs (Green and Blue respectively) which are used to determine a winner at the ending gate. /media/uploads/mdu7078/endinggate-1.png

Circuit diagram constructed using CircuitLab.

Usage

The mbed should be reset each time in order to clear the previous timing data. The tripwires should also be reset prior to this reset or else they will register again. The print button can be pressed at any time to print the timing results through a serial connection. If neither car has finished, the display will indicate this, or alternatively once each car has finished, its time will be shown.

Committer:
mdu7078
Date:
Sat Apr 20 18:31:09 2013 +0000
Revision:
0:bcdc97617c5d
Child:
1:d7651ce5d59b
First commit.  Basic operation.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mdu7078 0:bcdc97617c5d 1 /* * * * * * * * * * * * * * * * * * * * * * * * * * *
mdu7078 0:bcdc97617c5d 2 * This detects a winner in a two person race by *
mdu7078 0:bcdc97617c5d 3 * detecting when there is a break in the signal *
mdu7078 0:bcdc97617c5d 4 * sent to two different pins. When the winner is *
mdu7078 0:bcdc97617c5d 5 * detected, the corresponding LED is lit. *
mdu7078 0:bcdc97617c5d 6 * *
mdu7078 0:bcdc97617c5d 7 * Created by: Michael Dushkoff (mad1841@rit.edu) *
mdu7078 0:bcdc97617c5d 8 * * * * * * * * * * * * * * * * * * * * * * * * * * */
mdu7078 0:bcdc97617c5d 9 #include "mbed.h"
mdu7078 0:bcdc97617c5d 10
mdu7078 0:bcdc97617c5d 11 /* Interrupt sensors */
mdu7078 0:bcdc97617c5d 12 InterruptIn sEnd1(p20);
mdu7078 0:bcdc97617c5d 13 InterruptIn sEnd2(p21);
mdu7078 0:bcdc97617c5d 14
mdu7078 0:bcdc97617c5d 15 /* Indicator LEDs */
mdu7078 0:bcdc97617c5d 16 DigitalOut iled1(LED1);
mdu7078 0:bcdc97617c5d 17 DigitalOut iled2(LED2);
mdu7078 0:bcdc97617c5d 18
mdu7078 0:bcdc97617c5d 19 /* Tells when there is a winner */
mdu7078 0:bcdc97617c5d 20 int win = 0;
mdu7078 0:bcdc97617c5d 21
mdu7078 0:bcdc97617c5d 22 /* This detects interrupt 1 */
mdu7078 0:bcdc97617c5d 23 void l1(){
mdu7078 0:bcdc97617c5d 24 if (win == 0){
mdu7078 0:bcdc97617c5d 25 iled1 = 1;
mdu7078 0:bcdc97617c5d 26 win = 1;
mdu7078 0:bcdc97617c5d 27 }
mdu7078 0:bcdc97617c5d 28 }
mdu7078 0:bcdc97617c5d 29
mdu7078 0:bcdc97617c5d 30 /* This detects interrupt 2 */
mdu7078 0:bcdc97617c5d 31 void l2(){
mdu7078 0:bcdc97617c5d 32 if (win == 0){
mdu7078 0:bcdc97617c5d 33 iled2 = 1;
mdu7078 0:bcdc97617c5d 34 win = 1;
mdu7078 0:bcdc97617c5d 35 }
mdu7078 0:bcdc97617c5d 36 }
mdu7078 0:bcdc97617c5d 37
mdu7078 0:bcdc97617c5d 38 int main() {
mdu7078 0:bcdc97617c5d 39 /* Set the LEDs off */
mdu7078 0:bcdc97617c5d 40 iled1 = 0;
mdu7078 0:bcdc97617c5d 41 iled2 = 0;
mdu7078 0:bcdc97617c5d 42
mdu7078 0:bcdc97617c5d 43 /* Attach interrupt service routine to pins */
mdu7078 0:bcdc97617c5d 44 sEnd1.fall(&l1);
mdu7078 0:bcdc97617c5d 45 sEnd2.fall(&l2);
mdu7078 0:bcdc97617c5d 46
mdu7078 0:bcdc97617c5d 47 while(1) {
mdu7078 0:bcdc97617c5d 48 //Do nothing
mdu7078 0:bcdc97617c5d 49 }
mdu7078 0:bcdc97617c5d 50 }