interrupts are easy too.
Here's some of the basics of what you'll need.
You'll have to clean it up some to get it to compile, is mostly written as pseudo-code to get the ideas across.
How are you detecting the beams being broken?
You could start with a simple mechanical switch, the car hits it & shorts an input pin to gnd to cause the end of race interrupt.
// anything after double slash is a comment
#include <avr/interrupt.h> // interrupts library
// declare your interrupt pins. 2 & 3 are the external interrupts
int pin2 = 2; // int means data type integer
int pin3 = 3;
int car1done = 0;
int car2done = 0;
// for testing to start with, just turn a couple of LEDs on to check the interrupts are working
int LED1 = 4; // pin 4 to 330 ohm resistor to Anode of LED to gnd - write high to turn on
int LED2=5;
// define what you need for the LCD control
// Write a couple of ISRs to do this kind of functionality
//***************************************************
// * Name: pin2Interrupt, "ISR" to run when car 1 finishes
void pin2Interrupt()
{
// disable car 2 interrupts
// if (car 2 not done (== 0) ) {turn on car 1 done light and set a flag that car 1 is done}
// enable car 2 interrupts
// reset the done flags
}
//***************************************************
// * Name: pin3Interrupt, "ISR" to run when car 2 finishes
void pin3Interrupt()
{
// disable car 1 interrupts
// if (car 1 not done) {turn on car 2 done light and set a flag that car 2 is done}
// delay a second or two, then turn off done light
// enable car 1 interrupts
// reset the done flags
}
void setup()
// declare the pins as inputs with internal pullup resistors
pinMode (pin2, INPUT)
digitalWrite (pin2, HIGH)
pinMode (pin3, INPUT)
digitalWrite (pin3, HIGH)
// declare
pinMode (LED4, OUTPUT)
digitalWrite (LED4,LOW)
pinMode (LED5, OUTPUT)
digitalWrite (LED5, LOW)
void loop()
{
// now wait for the cars to start
// will need some attachInterrupt statements
/* Setup pin2 as an interrupt and attach handler. */
attachInterrupt(0, pin2Interrupt, LOW);
/* Setup pin3 as an interrupt and attach handler. */
attachInterrupt(1, pin3Interrupt, LOW);
}