Go Down

Topic: Drag racing practice tree  (Read 935 times) previous topic - next topic

paintbydexter

Looking for help building a Practice tree with reaction time LCD . Have looked on YouTube an there is more thin one video on this . With the code posted.  Using a push button like a " trans break". I won't to use a slot car controller not push button.   Not a trans brake .   Guys have controllers with that on it.     I won't this in a small box like a game . Have the led tree green light an a red . Thin tell the reaction time.    It's been done many videos with the button but no Wiring schematic to help me actually put it together. All these videos have the code but no Schematic.   

Would pay some one for there time


Dex

paintbydexter

#1
Nov 08, 2018, 05:53 am Last Edit: Nov 08, 2018, 05:58 am by paintbydexter
int ledPinR1 =19;//red light if jumped line
int ledPinG1 =18;//green light if sucessful
int ledPinY3 =8;//indicator light 3
int ledPinY2 =9;//indicator light 2
int ledPinY1 =10;//indicator light 1
int ledPinStageY1 =17;//staging light 1
int ledPinStageY2 = 16;//staging light 2
int buttonPin = 7;//button used to play game
int reactionTime;//holds final reaction time
int stage = 0;//holds each stage of the game
unsigned long startTime;//gets start time
unsigned long endTime;//gets end time
unsigned long rollout=240;//a delay for a drag car to actual start rolling due to the time it takes the powertrain to react
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup() {
  // put your setup code here, to run once:
pinMode(ledPinR1, OUTPUT);
pinMode(ledPinG1, OUTPUT);
pinMode(ledPinY3, OUTPUT);
pinMode(ledPinY2, OUTPUT);
pinMode(ledPinY1, OUTPUT);
pinMode(ledPinStageY1, OUTPUT);
pinMode(ledPinStageY2, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);

lcd.begin(20, 2);
lcd.print("Reaction Time:");
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

  lcd.setCursor(0, 1);
   
     //stops after each round and displays both staging lights to indicate ready
    if (digitalRead(buttonPin) == HIGH  && stage == 3)
    {     
     
       digitalWrite(ledPinStageY1,HIGH);
       digitalWrite(ledPinStageY2,HIGH);
      delay(2000);
      //sets stage to ready
       stage = 0;
     }

    //user indicated ready and now timer starts
    if (digitalRead(buttonPin) == LOW  && stage == 0)
    {     
       
       digitalWrite(ledPinStageY1,HIGH);
       digitalWrite(ledPinStageY2,HIGH);
       startTime = millis();
       stage = 1;
       delay(500);
     
     }
     
        //round finished and timer stopped
        if (digitalRead(buttonPin) == HIGH && stage ==1)
         {
             endTime = millis();
              digitalWrite(ledPinStageY2,LOW);
              digitalWrite(ledPinStageY1,LOW);
              digitalWrite(ledPinY1,LOW);
              digitalWrite(ledPinY2,LOW);
              digitalWrite(ledPinY3,LOW);
              stage =2;
         }

        //results sent here to indicate green or red light
        if (stage ==2)
         {
            //shows green if the user pressed button after yellow
            if((endTime+rollout) - startTime >=2000)
            {
            displayreactiontime();
           
            digitalWrite(ledPinG1,HIGH);
            delay(3000);
            digitalWrite(ledPinG1,LOW);
            stage=3;
            }
            //shows red if user pushed button before yellow
            if((endTime+rollout) - startTime <=2000)
            {
              //displays reaction time
            displayreactiontime();
            digitalWrite(ledPinR1,HIGH);
            delay(3000);
            digitalWrite(ledPinR1,LOW);
            stage=3;
            }
       
         }

        //used to go through 3 indicating lights
        if (digitalRead(buttonPin) == LOW  && stage ==1)       
       
         {
            if(millis() - startTime >= 500)
            {
            digitalWrite(ledPinY1, HIGH);  // Update the actual LED
            }
            if( millis() - startTime >= 1000)
            {
            digitalWrite(ledPinY1, LOW);  // Update the actual LED
            digitalWrite(ledPinY2, HIGH);  // Update the actual LED
            }
            if(millis() - startTime >= 1500)
            {
            digitalWrite(ledPinY2, LOW);  // Update the actual LED
            digitalWrite(ledPinY3, HIGH);  // Update the actual LED
            }
            if(millis() - startTime >= 2000)
            {
            digitalWrite(ledPinY3, LOW);  // Update the actual LED
         
            }
          }
 
       
}
//method calculates time
void displayreactiontime()
{
reactionTime = ((endTime+rollout)-startTime)- 2000;
Serial.print("Reaction time = ");
Serial.println(reactionTime);
lcd.println(reactionTime);








This works some what...... there is problems in said indicator lights.... should all be ... 1 on for .500 thin 2 on .500 3 on . It's like 3 stays on idk..... need this cleaned up....... an the LCD dose not work...... it dose have Liquidcrystal  include at top.   Just did not get copied

paintbydexter

Looking for any thang guys......

wvmarle

Imagine the people here know nothing about your project. They know nothing about drag racing beyond that it's got to do with cars and it's a popular pastime for American petrolheads.

Furthermore, imagine those people do know quite a bit on how to light LEDs in sequence, read buttons, and other specific inputs. The more defined the better.

Now please rewrite that description in terms those folk can understand, and I'm sure you'd get many more reactions. I for one have absolutely no clue what you're talking about in #0, largely as I have no clue what a "practice tree" could be in this context (we had a few trees popular to practice climbing in growing in the forest nearby our home but that has nothing to do with racing), and a "trans brake" is even more alien.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

patduino

Hi Dexter,

Are you looking for someone to build the tree or just give you the schematic for one and "fixed" software?
There are 10 types of people in the world, those who understand binary, and those that don't.

paintbydexter

Thanks for the reply guys.   Been working hard on this for a wile an no luck...

The schematic an code.       The one I have posted is close but not good at same time .

wvmarle

Thanks for the reply guys.   Been working hard on this for a wile an no luck...

The schematic an code.       The one I have posted is close but not good at same time .
Without clear description of what it does and how that's different from what you want it to do, no go. Same for this "tree" thing itself.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up