4 lane pinewood derby timer - newb

Hi guys, I am trying to modify code for a 2 lane pinewood derby timer to make it detect and time 4 lanes. This is the circuit schematic for the 2 lane version:


This is the original code:


And these are my modifications:


I am a newb, and I would love to know 1. will this work? and 2. Are there ways to improve this code? Any help would be much appreciated. I am trying to learn both coding and making circuits with this project. Thanks in advance.

Hi, This looks OK, (without being able to run it).. Pins look OK...

Are you having problems?

You could breadboard this with the LEDS/Phototransiostors just pointing at each other and use your hand to 'simulate' cars...

Some low-cost parts here: Infrared http://goo.gl/Wh093

DISCLAIMER: Mentioned stuff from my own shop...

It is not readily available, but -

There is another way of accessing I/O that has some potential for problems...

Search for PORTB and DDRB and PINB (and PIRTC, DDRC, PORTD and DDRD

These are ways of accessing a port directly so that you can read or write multiple pins at one time.

You can still set up the pins in the normal method and then use PORTB to read them. If you look at the Arduino pinouts you will notice that they have notoation like this 328 Arduino PB0 D8 PB1 D9 PB2 D10 PB3 D11

so you could do a quick read of pins d8 through d11

MyVar = PORTB and 15 if myvar = 1 then track 1 was tripped = 2 then track 2, 4 tehn track 4 and 8 would be track 4. Combinations would mean that there was a tie.

you could then loop waiting for finisher 1, another loop for finisher 2, another loop for finisher 3 and then assume that finisher 4 was whoever is left.

When you check each bit individually you are increasing the chance that you will miss a car if they are close.