Pages: [1]   Go Down
Author Topic: 4 lane pinewood derby timer - newb  (Read 402 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Topsham, Vermont USA
Offline Offline
Edison Member
Karma: 33
Posts: 1926
... in The Woods In Vermont
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

DISCLAIMER: Mentioned stuff from my own shop...

Regards, Terry King  - Check great prices, devices and Arduino-related boards at
HOW-TO: http://ArduinoInfo.Info

South Texas
Offline Offline
Edison Member
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Pages: [1]   Go Up
Jump to: