Instructables
I'm new to Arduino so I was excited to try this out.  I also Drag race 1/24 scale slotcars.  I built a homemade 24' drag strip to practice. I need the tree to be the same as the race track  so my reaction time might  improve.  I'm not sure if I have the timing right, but it's getting close. See the video below.



The Arduino = Arduino UNO purchased at Radio Shack

The Breadboard=  Radio Shack (not necessary, but I already made the prototyping stand.  http://www.instructables.com/id/Acrylic-Arduino-Prototyping-Stand/)

LEDs and jumper wires = you guessed it... Radio Shack

The power source is Altoids charger that supply's 5v to the Arduino board  ( http://www.instructables.com/id/Another-Altoids-Ipod-Charger/)
You can also use a 9v battery with  resistors that are appropriate or use usb from laptop or desk top computer.  

The software I used I downloaded from  http://arduino.cc/en/Main/Software

I understand there are many ways one can do this. I chose to build it this way because this is what I had.  

I connected the jumper wires to the #2,4,6,8,10 pins found on the Arduino board and the long leg of the Led are placed in line with the end of the red jumper wires on the breadboard.
.
The ground pin is located above the #13 pin  (GND) on the Arduino board. 


The Code I wrote is a modified version of the blink example: 

/*
  Blink
  Turns on an LED on for 1 second, then off for 1 second.
 
  This example code is in the public domain.
*/



void setup() {
 
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(2, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(10, OUTPUT);
}

void loop() {
  digitalWrite(2, HIGH);  // White Led on for 1 second
  delay(1000);            
  digitalWrite(2, LOW);   // LED turns off for 1/2 second  
  delay(500);             
  digitalWrite(4, HIGH);  // Yellow led on 1/2 second   
  delay(500); 
  digitalWrite(4, LOW);   // LED turns off for 1/2 second
  delay(500);  
  digitalWrite(6, HIGH);  // Yellow Led on for 1/2 second
  delay(500);            
  digitalWrite(6, LOW);   // LED turns off for 1/2 second
  delay(500);             
  digitalWrite(8, HIGH);  // Yellow Led on for 1/2 sec 
  delay(500); 
  digitalWrite(8, LOW);   // LED turns off for 1/2 second
  delay(500);
  digitalWrite(10, HIGH);   // Green Led on for 2 seconds
  delay(2000);            
  digitalWrite(10, LOW);   // Green LED turns off for 3 seconds
    delay(3000);
}






As soon as I learn how to move it to it's own board and add a start switch I will put it in a box and mount it permanently.
 

Can this be scaled up to maybe 1/8 Scale ?

biomech752 years ago
and some 220 Ohm too so the leds will last longer.

the leds aren't lit for long enough in the code to harm the leds they need extended periods of overcurrent to fry! Cheers

Super cool. I was going to make one. Had one instructable in progress before I saw this one but deleted it. might go back and work on it again. I wanted lights for both tracks and test for early start.
dsxmastree.png
ea422 (author)  Computothought2 years ago
That would be great. I am so new to this that I had to start as easy as possible.
I hope you do finish yours so I can learn from it.
Looks like your doing pretty well.
biomech752 years ago
Here is the same code but with some modifications. I have change the timing and adde another white led I have been drag racing almost all of my life (EVOs, Hondas, RX7's) and I think It looks more closer to the real "Tree Light". And I do not want you to think that you are wrong on your instructurable. I just want to help you making the best Tree Light for your practices. ;)
First I add another white led. That one is Pre Stage (Pin 2) and the second one is for the Stage (Pin 3). Then I have change timing in between the leds so here is the code:

/*
Blink
Turns on an LED on for 1 second, then off for 1 second.

This example code is in the public domain.
*/



void setup() {

// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(6, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
}

void loop() {
digitalWrite(2, HIGH); // White Led on for 2 second Pre Stage
delay(2000);
digitalWrite(2, LOW); // LED turns off for 1/2 second
delay(5);
digitalWrite(3, HIGH); // White Led on for 1 second Stage
delay(1000);
digitalWrite(3, LOW); // LED turns off for 1/2 second
delay(5);
digitalWrite(4, HIGH); // Yellow led on 1/2 second
delay(500);
digitalWrite(4, LOW); // LED turns off for 1/2 second
delay(5);
digitalWrite(6, HIGH); // Yellow Led on for 1/2 second
delay(500);
digitalWrite(6, LOW); // LED turns off for 1/2 second
delay(5);
digitalWrite(8, HIGH); // Yellow Led on for 1/2 sec
delay(500);
digitalWrite(8, LOW); // LED turns off for 1/2 second
delay(5);
digitalWrite(10, HIGH); // Green Led on for 5 seconds
delay(5000);
digitalWrite(10, LOW); // Green LED turns off for 5 seconds
delay(5000);
}

ENJOY DRAG RACING
ea422 (author)  biomech752 years ago
I will definitely use this and try to figure out the photocell. Eventually I would like to add a stopwatch that starts and stops for each car. I know it can be done, but still way over my head for now. Thanks for your input.
biomech75 ea4222 years ago
for the stop watch you can use an bicycle odometer that can measure time and miles theyre cheaper @ wallmart
biomech752 years ago
....And at the finish line install a photocell with another ATtiny Arduino to see who won. you need :
•220-Ohm resistor
•LED
•Photocell
•10k resistor

here is the Sketch:

int photocellPin = 0;// Photocell connected to analog pin 0
int photocellVal = 0; // define photocell variable
int ledPin = 9;// LED connected to digital pin 9
int ledState = 0;//state of the led
int fadeDown = 30;//delay per fade
int fadeUp = 20;//delay per fade
int minLight = 100;//min light threshold
int maxLight = 100;//max light threshold


void setup() {
//Serial.begin(9600);
pinMode(photocellPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
photocellVal = analogRead(photocellPin);

if (photocellVal < minLight and ledState == 0){
fadeLed(1);
//Serial.println("fade up");
}
else if (photocellVal > maxLight and ledState == 1){
fadeLed(0);
// Serial.println("fade down");
}



}

void fadeLed(int num){
if (num == 1){
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPin, fadeValue);
delay(fadeUp);
}
ledState = 1;

}
else{
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPin, fadeValue);
delay(fadeDown);
}
ledState = 0;
}


}
photocell .jpg
biomech752 years ago
Also you can add the red "foul" light and a photocell for the pre stage and stage lights
ea422 (author)  biomech752 years ago
I would like to add the foul light. I am still learning how this works. I'm hoping to use larger lights as well.
biomech752 years ago
AND.... for this project If I were you I should buy an ATtiny 45/85 arduino IC so you don't have to sacrifice your regular Arduino and you can continue doing projects. ATtiny is perfect for this project I have tried with that code I have post. ;)
biomech752 years ago
The connections are not clear and where is the GND and 5V connection
just a comment but it looks great your project
ea422 (author)  biomech752 years ago
Good point! I will update it this evening. Thanks!