How to Connect Ir Module wirh solonoid and Stop Watch for NERDY DERBY

I Need Help!.. This is my first Arduino project ever. I’m a computer Science student. but I’m still on my first semester. i am currently on a semester break.So i have the basic of C++ such as Array, Looping, Control Structure and If Else statement. but thats about it. So, im trying to build a NERDY DERBY track…
but theres a few errors that i could not understand. So, Ive done solonoid, Ir Module and The StopWatch separately and it work’s separately with a nano. Now I’m trying to connect all three under one nano and one code. but i dont know how. Need Help ASAP !! :’( :’( :’( :’( :’( :’( :’( :’( :’(

NERDYDERBYBRAIN.ino (3.1 KB)

irmodule.ino (1.47 KB)

Solenoid_with_Button.ino (707 Bytes)

timerdisplay.ino (650 Bytes)

This isn't an installation or troubleshooting question, is it?

is it??

I Need Help!.. This is my first Arduino project ever. I’m a computer Science student. but I’m still on my first semester. i am currently on a semester break.So i have the basic of C++ such as Array, Looping, Control Structure and If Else statement. but thats about it. So, im trying to build a NERDY DERBY track…
but theres a few errors that i could not understand. So, Ive done solonoid, Ir Module and The StopWatch separately and it work’s separately with a nano. Now I’m trying to connect all three under one nano and one code. but i dont know how. Need Help ASAP !! :’( :’( :’( :’( :’( :’( :’( :’( :’(

irmodule.ino (1.47 KB)

Solenoid_with_Button.ino (707 Bytes)

timerdisplay.ino (650 Bytes)

NERDYDERBYBRAIN.ino (3.1 KB)

Please read the "how to use this forum-please read" stickies to see how to post code and error messages.

#include <Arduino.h>
#include <TM1637Display.h>

//Stopwatch
int LED = 13;
int S1 = 12;
int hasObstacle1 = 1;
int hasObstacle2 = 1;
int hasObstacle3 = 1;
int clk1 = A1;
int dio1 = A2;
int clk2 = A3;
int dio2 = A4;
int clk3 = A5;
int dio3 = A6;
int i = 0;
#define numberOfSeconds(_time_) ((_time_ / 1000) % 60)  ;
#define numberOfMinutes(_time_) (((_time_ / 1000) / 60) % 60) ;
 display(clk1, dio1);
 display(clk2, dio2);
 display(clk3, dio3);
 
 display.showNumberDec(i,true,4,0);



// IR MODULE DATATYPE
int LED = 13; 
int obstaclePin4 = 7;  // This is our input pin
int obstaclePin5 = 8;
int obstaclePin6 = 9;

int hasObstacle4 = HIGH;
int hasObstacle5 = HIGH;
int hasObstacle6 = HIGH;

// SOLENOID DATATYPE
int solenoidPin1 = 2;
int solenoidPin2 = 3;
int solenoidPin3 = 4;

const int buttonPin= A5;
 
int buttonState = 0;


int i = 0;

void setup() 
{     
    
  pinMode(buttonPin, INPUT);
  pinMode(solenoidPin1 , OUTPUT);
  pinMode(solenoidPin2 , OUTPUT);
  pinMode(solenoidPin3 , OUTPUT);
  
  pinMode(LED, OUTPUT);
  pinMode(obstaclePin4, INPUT);
  pinMode(obstaclePin5, INPUT);
  pinMode(obstaclePin6, INPUT);
  Serial.begin(9600); 

  display.setBrightness(0x0c);   
  pinMode(LED, OUTPUT);
  pinMode(S1, INPUT)
 
  
  
}

void loop() 
{
 
  buttonState = digitalRead(buttonPin);
  stopwatch();
  if (buttonState == HIGH)
  {
    stopwatch();
    digitalWrite(solenoidPin1, HIGH);
    digitalWrite(solenoidPin2, HIGH);
    digitalWrite(solenoidPin3, HIGH);
    delay(3000);
    check();
      if (hasObstacle4 == HIGH){
          hasObstacle1 = 0;
      }
      if (hasObstacle5 == HIGH){
         hasObstacle2 = 0;
      }
      if (hasObstacle6 == HIGH){
          hasObstacle3 = 0;
       }
  } 
  else 
  { 
    stopwatch();
    digitalWrite(solenoidPin1, LOW);
    digitalWrite(solenoidPin2, LOW);
    digitalWrite(solenoidPin3, LOW); 
    delay(3000);
    check();   
  }

   if (hasObstacle4 == LOW){
          hasObstacle1 = 1;
      }
   if (hasObstacle5 == LOW){
          hasObstacle2 = 1;
      }
   if (hasObstacle6 == LOW){
          hasObstacle3 = 1;
       }
}


void check()
{
  if (hasObstacle == LOW) //LOW means something is ahead, so illuminates the 13th Port connected LED
  {
    Serial.println("Stop something is ahead at IR1!!");
    digitalWrite(LED, HIGH);//Illuminates the 13th Port LED
    
  }
  else
  {
    Serial.println("Path at IR1 is clear");
    digitalWrite(LED, LOW);
    
  }
  
  if (hasObstacle2 == LOW) //LOW means something is ahead, so illuminates the 13th Port connected LED
  {
    Serial.println("Stop something is ahead at IR2!!");
    digitalWrite(LED, HIGH);//Illuminates the 13th Port LED
    
  }
  else
  {
    Serial.println("Path AT IR2 is clear");
    digitalWrite(LED, LOW);
    
  }
  
  if (hasObstacle3 == LOW) //LOW means something is ahead, so illuminates the 13th Port connected LED
  {
    Serial.println("Stop something is ahead at IR3!!");
    digitalWrite(LED, HIGH);//Illuminates the 13th Port LED
    
  }
  else
  {
    Serial.println("Path at IR3 is clear");
    digitalWrite(LED, LOW);
    
  }
  delay(0);
}

void stopwatch()
{
 while(i<6000)
 {
   display.showNumberDec(i,true,4,0);
   i= i+2;
   delay(0); 
 }
}

Errors:

Combining codes.
Merge sketches.

You never changed the value of hasObstacle

You already have 4 posts about this project in Project Guidance. Please do not cross post.

@MichealDapeah, do not cross-post again. Threads merged.

Put a little thought into it. You won't learn if we do it for you. Also, please explain how the 4 codes you posted work, what they do, and what you would like the final product to do.

My suggestion is to simply understand the code you are working with and think of when you want them to run. Then you can either put them in as part of a conditional statement or as a function in the main loop.