Im having an issue with my code

hi, i don't even know if this code is correct but im trying to add a 1 second delay before the first pulse out and then no delay with the second pulse out here is the code

//KaizenRelay Template
//Version 4.0 - 2022 January 22
//Kaizen Speed, LLC. - Vadim Belogorodsky

void EnableGreenLED();
void DisableGreenLED();

void EnableRedLED();
void DisableRedLED();

#include "KaizenRelay.h"

#define UseGenericCANRx 0
#define UseGenericCANTx 0

//Program Variable Area:
bool InputState = false;
bool InputStateLast = false;
byte PulsePhase = 0;
bool PulseTimerRunning = false;
unsigned int PulseTimer = 0;

void setup()
{
//Setup Pins and CAN Timer:
HardwareSetup();

//Input Pin 1 Setup:
//Enable5VSupply();
//Disable5VSupply();
//EnableInput1Pullup();
//DisableInput1Pullup();
EnableInput1Pulldown();
//DisableInput1Pulldown();
//DisableInput1Switches();

//Input Pin 2 Setup:
//EnableInput2Pullup();
//DisableInput2Pullup();
//EnableInput2Pulldown();
//DisableInput2Pulldown();
DisableInput2Switches();

//Input Pin 3 Setup:
//EnableInput3Pullup();
//DisableInput3Pullup();
//EnableInput3Pulldown();
//DisableInput3Pulldown();
DisableInput3Switches();

//Output Pin 1 Setup:
Output_1_Mode = 2;

//Output Pin 2 Setup:
Output_2_Mode = 2;

//Output Pin 3 Setup:
Output_3_Mode = 0;

//Output PWM Setup:
//SetupPWM10Hz();
//SetupPWM50Hz();
//SetupPWM100Hz();

//CAN Baud Rate Setup:
//SetupCAN_125kbps();
//SetupCAN_250kbps();
//SetupCAN_500kbps();
//SetupCAN_1000kbps();

//CAN Termination Resistor:
//EnableCANTermResistor();
DisableCANTermResistor();

//Setup USB Interface
Serial.begin(57600);
}

void loop()
{
//Check if CAN Messages are Available
if(CAN_MSGAVAIL == CAN_.checkReceive())
{
//Read in CAN Message Length and Data
CAN_.readMsgBuf(&CAN_Read_Len, CAN_Read_Msg);

//Read in CAN Message ID
CAN_Read_ID = CAN_.getCanId();

//Generic CAN Listen
if(UseGenericCANRx)
{
	if((CAN_Read_ID >= CAN_Base_Address + 7) && (CAN_Read_ID <= CAN_Base_Address + 10)) 
		CANListenMsg();
}
CAN_MissedMsgs = 0;

}
else CAN_MissedMsgs++;

CAN_Timeout = (CAN_MissedMsgs > 10000);

//Variable Overflow Handle
if(CAN_MissedMsgs > 60000) CAN_MissedMsgs = 11000;

//Check if Serial Messages are Available()
if(Serial.available())
{
while(Serial.available())
{
SerialInput += (char)Serial.read();
}

SerialIndex = SerialInput.substring(0, 3);
SerialData = SerialInput.substring(4, SerialInput.length());

ReadHWStatusUSB();

SerialInput = "";    

}

if(Flag10ms)
{
Timer10ms();
Flag10ms = false;
}

if(Flag20ms && !Flag10ms)
{
Timer20ms();
Flag20ms = false;
}

if(Flag50ms && !Flag20ms && !Flag10ms)
{
Timer50ms();
Flag50ms = false;
}

if(Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
{
Timer100ms();
Flag100ms = false;
}

if(Flag500ms && !Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
{
Timer500ms();
Flag500ms = false;
}

if(Flag1000ms && !Flag500ms && !Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
{
Timer1000ms();
Flag1000ms = false;
}
}

//This sets a timer delay for the output pin if voltage is suplied to the input and sets delay for the ouput once voltage is removed from the input.
void loop() {
// Check if the input is high
if (digitalRead(Input1Digital) == HIGH && !isInputHigh) {
// Input is detected, wait one second and set output1 high
delay(1000);
digitalWrite(Output1Digital, HIGH);
isInputHigh = true;
} else if (digitalRead(Input1Digital) == LOW && isInputHigh) {
// Input is gone, wait 1 second and set output 1 low
delay(1000);
digitalWrite(Output1Digital, LOW);
isInputHigh = false;
}
}

void USB_Write()
{
//User Area for USB Writing - Message Beginning ""
Serial.print("
");

//Place Your Required Text Output Here -- for example:
Serial.print("In: "); Serial.print(Input_1_Digital);
Serial.print(", Ph: "); Serial.print(PulsePhase);
//Serial.print(", T_RunnRunning: "); Serial.print(PulseTimerRunning);
Serial.print(", Tmr: "); Serial.print(PulseTimer);
Serial.print(", Out: "); Serial.print(Output_1_Digital);

//Message Ending ";"
Serial.println(";");
}
void Timer10ms()
{
if(UseGenericCANTx) SendHWStatusCAN();

Input_1_Digital = ReadInput1Digital(false);
InputState = Input_1_Digital;
if(InputState != InputStateLast)
{
if(!InputState) //On to Off
{
PulsePhase = 1;
PulseTimer = 0;
PulseTimerRunning = true;
}

if(InputState) //Off to On
{
  PulsePhase = 2;
  PulseTimer = 0;
  PulseTimerRunning = true;
}

}
InputStateLast = InputState;

if(PulseTimerRunning) PulseTimer++;
if(PulseTimer > 20000) PulseTimer = 10000;

if(PulsePhase == 1)
{
if(PulseTimerRunning && (PulseTimer < 50)) {DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
if(PulseTimerRunning && ((PulseTimer >= 50) && (PulseTimer < 100))) {EnableOutput1Digital(); DisableOutput2Digital(); EnableGreenLED();}
if(PulseTimer == 100) {PulsePhase = 0; PulseTimerRunning = false; DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
}

if(PulsePhase == 2)
{
if(PulseTimerRunning && (PulseTimer <= 50)) {EnableOutput1Digital(); DisableOutput2Digital(); EnableGreenLED();}
if(PulseTimer == 50) {PulsePhase = 0; PulseTimerRunning = false; DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
}
}

void Timer20ms()
{
USB_Write();
}

void Timer50ms()
{
SendHWStatusUSB();
}

void Timer100ms()
{

}

void Timer500ms()
{

}

void Timer1000ms()
{
//Generic CAN Listen
if(UseGenericCANRx)
{
if(CAN_Timeout)
{
//CAN Error
if(Output_1_Mode == 1) Output_1_Duty = 0;
if(Output_1_Mode == 2) DisableOutput1Digital();
Output_1_Mode = 0;

  if(Output_2_Mode == 1) Output_2_Duty = 0;
  if(Output_2_Mode == 2) DisableOutput2Digital();
  Output_2_Mode = 0; 

  if(Output_3_Mode == 1) Output_3_Duty = 0;
  if(Output_3_Mode == 2) DisableOutput3Digital();
  Output_3_Mode = 0; 

  DisableGreenLED();
  DisableRedLED();
}  

}
}

ISR(TIMER1_COMPA_vect) //Timer1 Interrupt
{
PWMpulseCounter++;
if(PWMpulseCounter >= 99) PWMpulseCounter = 0;

//Port Manipulation:

/*
//Green LED: PD1
if(xxx)
{
if(PWMpulseCounter < Output_x_Duty) PORTD = PORTD | 0b00000010;
else PORTD = PORTD & 0b11111101;
}

//Red LED: PD0
if(xxx)
{
if(PWMpulseCounter < Output_y_Duty) PORTD = PORTD | 0b00000001;
else PORTD = PORTD & 0b11111110;
}

*/

//Output 1: PB5
if(Output_1_Mode == 1)
{
if(PWMpulseCounter < Output_1_Duty) PORTB = PORTB | 0b00100000;
else PORTB = PORTB & 0b11011111;
}

//Output 2: PC7
if(Output_2_Mode == 1)
{
if(PWMpulseCounter < Output_2_Duty) PORTC = PORTC | 0b10000000;
else PORTC = PORTC & 0b01111111;
}

//Output 3: PC6
if(Output_3_Mode == 1)
{
if(PWMpulseCounter < Output_3_Duty) PORTC = PORTC | 0b01000000;
else PORTC = PORTC & 0b10111111;
}
}

void CANListenMsg()
{
if(CAN_Read_ID == (CAN_Base_Address + 7))
{
if(CAN_Read_Msg[0] == 0x01)
{
Output_1_Mode = 2;
}
else if (CAN_Read_Msg[0] == 0x02)
{
Output_1_Mode = 1;
if(Output_1_PWMFreq != 10) SetupPWM10Hz();
}

else if (CAN_Read_Msg[0] == 0x04)
{
  Output_1_Mode = 1;
  if(Output_1_PWMFreq != 50) SetupPWM50Hz();
}

else if (CAN_Read_Msg[0] == 0x08)
{
  Output_1_Mode = 1;
  if(Output_1_PWMFreq != 100) SetupPWM100Hz();
}
else 
{
  Output_1_Digital = false;
  Output_1_Duty = 0;
  Output_1_Mode = 0;
}

if(Output_1_Mode == 2)
{
  if(CAN_Read_Msg[1]) EnableOutput1Digital();
  else DisableOutput1Digital();
}

if(Output_1_Mode == 1)
{
  DisableOutput1Digital();
  if(CAN_Read_Msg[1] <= 100) Output_1_Duty = CAN_Read_Msg[1];
  else Output_1_Duty = 0;      
}

}

if(CAN_Read_ID == (CAN_Base_Address + 8))
{
if(CAN_Read_Msg[0] == 0x01)
{
Output_2_Mode = 2;
}
else if (CAN_Read_Msg[0] == 0x02)
{
Output_2_Mode = 1;
if(Output_2_PWMFreq != 10) SetupPWM10Hz();
}

else if (CAN_Read_Msg[0] == 0x04)
{
  Output_2_Mode = 1;
  if(Output_2_PWMFreq != 50) SetupPWM50Hz();
}

else if (CAN_Read_Msg[0] == 0x08)
{
  Output_2_Mode = 1;
  if(Output_2_PWMFreq != 100) SetupPWM100Hz();
}
else 
{
  Output_2_Digital = false;
  Output_2_Duty = 0;
  Output_2_Mode = 0;
}

if(Output_2_Mode == 2)
{
  if(CAN_Read_Msg[1]) EnableOutput2Digital();
  else DisableOutput2Digital();
}

if(Output_2_Mode == 1)
{
  DisableOutput2Digital();
  if(CAN_Read_Msg[1] <= 100) Output_2_Duty = CAN_Read_Msg[1];
  else Output_2_Duty = 0;      
}

}

if(CAN_Read_ID == (CAN_Base_Address + 9))
{
if(CAN_Read_Msg[0] == 0x01)
{
Output_3_Mode = 2;
}
else if (CAN_Read_Msg[0] == 0x02)
{
Output_3_Mode = 1;
if(Output_3_PWMFreq != 10) SetupPWM10Hz();
}

else if (CAN_Read_Msg[0] == 0x04)
{
  Output_3_Mode = 1;
  if(Output_3_PWMFreq != 50) SetupPWM50Hz();
}

else if (CAN_Read_Msg[0] == 0x08)
{
  Output_3_Mode = 1;
  if(Output_3_PWMFreq != 100) SetupPWM100Hz();
}
else
{
  Output_3_Digital = false;
  Output_3_Duty = 0;
  Output_3_Mode = 0;
}

if(Output_3_Mode == 2)
{
  if(CAN_Read_Msg[1]) EnableOutput3Digital();
  else DisableOutput3Digital();
}

if(Output_3_Mode == 1)
{
  DisableOutput3Digital();
  if(CAN_Read_Msg[1] <= 100) Output_3_Duty = CAN_Read_Msg[1];
  else Output_3_Duty = 0;      
}

}

if(CAN_Read_ID == (CAN_Base_Address + 10))
{
if(CAN_Read_Msg[0] & 0x01) EnableCANTermResistor();
else DisableCANTermResistor();

if(CAN_Read_Msg[0] & 0x02) EnableGreenLED();
else DisableGreenLED();

if(CAN_Read_Msg[0] & 0x04) EnableRedLED();
else DisableRedLED();

}
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

```cpp
//KaizenRelay Template
//Version 4.0 - 2022 January 22
//Kaizen Speed, LLC. - Vadim Belogorodsky

void EnableGreenLED();
void DisableGreenLED();

void EnableRedLED();
void DisableRedLED();

#include "KaizenRelay.h"

#define UseGenericCANRx 0               
#define UseGenericCANTx 0

//Program Variable Area:
bool InputState = false;
bool InputStateLast = false;
byte PulsePhase = 0;
bool PulseTimerRunning = false;
unsigned int PulseTimer = 0;

void setup() 
{
  //Setup Pins and CAN Timer:
  HardwareSetup();

  //Input Pin 1 Setup:
  //Enable5VSupply();
  //Disable5VSupply();
  //EnableInput1Pullup();
  //DisableInput1Pullup();
  EnableInput1Pulldown();
  //DisableInput1Pulldown();
  //DisableInput1Switches();

  //Input Pin 2 Setup:
  //EnableInput2Pullup();
  //DisableInput2Pullup();
  //EnableInput2Pulldown();
  //DisableInput2Pulldown();
  DisableInput2Switches();

  //Input Pin 3 Setup:
  //EnableInput3Pullup();
  //DisableInput3Pullup();
  //EnableInput3Pulldown();
  //DisableInput3Pulldown();
  DisableInput3Switches();
  
  //Output Pin 1 Setup:
  Output_1_Mode = 2;

  //Output Pin 2 Setup:
  Output_2_Mode = 2;

  //Output Pin 3 Setup:
  Output_3_Mode = 0;

  //Output PWM Setup:
  //SetupPWM10Hz();
  //SetupPWM50Hz();
  //SetupPWM100Hz();

  //CAN Baud Rate Setup:
  //SetupCAN_125kbps();
  //SetupCAN_250kbps();
  //SetupCAN_500kbps();
  //SetupCAN_1000kbps();
  
  //CAN Termination Resistor:
  //EnableCANTermResistor();
  DisableCANTermResistor();

  //Setup USB Interface
  Serial.begin(57600);
}

void loop() 
{
  //Check if CAN Messages are Available
  if(CAN_MSGAVAIL == CAN_.checkReceive())
  {
    //Read in CAN Message Length and Data
    CAN_.readMsgBuf(&CAN_Read_Len, CAN_Read_Msg);

    //Read in CAN Message ID
    CAN_Read_ID = CAN_.getCanId();

    //Generic CAN Listen
    if(UseGenericCANRx)
  	{
  		if((CAN_Read_ID >= CAN_Base_Address + 7) && (CAN_Read_ID <= CAN_Base_Address + 10)) 
  			CANListenMsg();
  	}
    CAN_MissedMsgs = 0;
  }
  else CAN_MissedMsgs++;

  CAN_Timeout = (CAN_MissedMsgs > 10000);

  //Variable Overflow Handle
  if(CAN_MissedMsgs > 60000) CAN_MissedMsgs = 11000;

  //Check if Serial Messages are Available()
  if(Serial.available())
  {    
    while(Serial.available()) 
    {
      SerialInput += (char)Serial.read();
    }

    SerialIndex = SerialInput.substring(0, 3);
    SerialData = SerialInput.substring(4, SerialInput.length());

    ReadHWStatusUSB();
    
    SerialInput = "";    
  }

  if(Flag10ms)
  {
    Timer10ms(); 
    Flag10ms = false;
  }

  if(Flag20ms && !Flag10ms)
  {
    Timer20ms(); 
    Flag20ms = false;
  }

  if(Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer50ms(); 
    Flag50ms = false;
  }
  
  if(Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer100ms(); 
    Flag100ms = false;
  }
  
  if(Flag500ms && !Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer500ms(); 
    Flag500ms = false;
  }

  if(Flag1000ms && !Flag500ms && !Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer1000ms(); 
    Flag1000ms = false;
  }
}

//This sets a timer delay for the output pin if voltage is suplied to the input and sets delay for the ouput once voltage is removed from the input.
void loop_2() {
  // Check if the input is high
  if (digitalRead(Input_1_Digital) == HIGH && !isInputHigh) {
    // Input is detected, wait one second and set output1 high 
    delay(1000);
    digitalWrite(Output1Digital, HIGH);
    isInputHigh = true;
  } else if (digitalRead(Input1Digital) == LOW && isInputHigh) {
    // Input is gone, wait 1 second and set output 1 low
    delay(1000);
    digitalWrite(Output1Digital, LOW);
    isInputHigh = false;
  }
}

void USB_Write()
{
  //User Area for USB Writing - Message Beginning "**"
  Serial.print("**");

  //Place Your Required Text Output Here -- for example:
  Serial.print("In: "); Serial.print(Input_1_Digital); 
  Serial.print(", Ph: "); Serial.print(PulsePhase);
  //Serial.print(", T_RunnRunning: "); Serial.print(PulseTimerRunning); 
  Serial.print(", Tmr: "); Serial.print(PulseTimer); 
  Serial.print(", Out: "); Serial.print(Output_1_Digital);
  
  //Message Ending ";"
  Serial.println(";");
} 
void Timer10ms()
{
  if(UseGenericCANTx) SendHWStatusCAN();

  Input_1_Digital = ReadInput1Digital(false);
  InputState = Input_1_Digital;
  if(InputState != InputStateLast)
  {
    if(!InputState) //On to Off
    {
      PulsePhase = 1;
      PulseTimer = 0;
      PulseTimerRunning = true;
    }

    if(InputState) //Off to On
    {
      PulsePhase = 2;
      PulseTimer = 0;
      PulseTimerRunning = true;
    }
  }
  InputStateLast = InputState;



  if(PulseTimerRunning) PulseTimer++;
  if(PulseTimer > 20000) PulseTimer = 10000;

  if(PulsePhase == 1)
  {
    if(PulseTimerRunning && (PulseTimer < 50)) {DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
    if(PulseTimerRunning && ((PulseTimer >= 50) && (PulseTimer < 100))) {EnableOutput1Digital(); DisableOutput2Digital(); EnableGreenLED();}
    if(PulseTimer == 100) {PulsePhase = 0; PulseTimerRunning = false; DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
  }

  if(PulsePhase == 2)
  {
    if(PulseTimerRunning && (PulseTimer <= 50)) {EnableOutput1Digital(); DisableOutput2Digital(); EnableGreenLED();}
    if(PulseTimer == 50) {PulsePhase = 0; PulseTimerRunning = false; DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
  }
}

void Timer20ms()
{
    USB_Write();
}

void Timer50ms()
{
  SendHWStatusUSB();
}

void Timer100ms()
{
  
}

void Timer500ms()
{
  
}

void Timer1000ms()
{
  //Generic CAN Listen
  if(UseGenericCANRx)
  {
    if(CAN_Timeout)
    {
      //CAN Error
      if(Output_1_Mode == 1) Output_1_Duty = 0; 
      if(Output_1_Mode == 2) DisableOutput1Digital(); 
      Output_1_Mode = 0; 
  
      if(Output_2_Mode == 1) Output_2_Duty = 0;
      if(Output_2_Mode == 2) DisableOutput2Digital();
      Output_2_Mode = 0; 
  
      if(Output_3_Mode == 1) Output_3_Duty = 0;
      if(Output_3_Mode == 2) DisableOutput3Digital();
      Output_3_Mode = 0; 
  
      DisableGreenLED();
      DisableRedLED();
    }  
  }
}



ISR(TIMER1_COMPA_vect) //Timer1 Interrupt 
{
  PWMpulseCounter++;
  if(PWMpulseCounter >= 99) PWMpulseCounter = 0;

  //Port Manipulation:
  
/*  
  //Green LED: PD1
  if(xxx)
  {
    if(PWMpulseCounter < Output_x_Duty) PORTD = PORTD | 0b00000010;
    else                                PORTD = PORTD & 0b11111101; 
  }

  //Red LED: PD0
  if(xxx)
  {
    if(PWMpulseCounter < Output_y_Duty) PORTD = PORTD | 0b00000001;
    else                                PORTD = PORTD & 0b11111110; 
  }

*/
  
  //Output 1: PB5
  if(Output_1_Mode == 1)
  {
    if(PWMpulseCounter < Output_1_Duty) PORTB = PORTB | 0b00100000;
    else                                PORTB = PORTB & 0b11011111; 
  }
  
  //Output 2: PC7
  if(Output_2_Mode == 1)
  {
    if(PWMpulseCounter < Output_2_Duty) PORTC = PORTC | 0b10000000;
    else                                PORTC = PORTC & 0b01111111;
  }
    
  //Output 3: PC6  
  if(Output_3_Mode == 1)
  {
    if(PWMpulseCounter < Output_3_Duty) PORTC = PORTC | 0b01000000;
    else                                PORTC = PORTC & 0b10111111;
  }
}

void CANListenMsg()
{
  if(CAN_Read_ID == (CAN_Base_Address + 7))
  {
    if(CAN_Read_Msg[0] == 0x01)
    {
      Output_1_Mode = 2;
    }
    else if (CAN_Read_Msg[0] == 0x02)
    {
      Output_1_Mode = 1;
      if(Output_1_PWMFreq != 10) SetupPWM10Hz();
    }

    else if (CAN_Read_Msg[0] == 0x04)
    {
      Output_1_Mode = 1;
      if(Output_1_PWMFreq != 50) SetupPWM50Hz();
    }

    else if (CAN_Read_Msg[0] == 0x08)
    {
      Output_1_Mode = 1;
      if(Output_1_PWMFreq != 100) SetupPWM100Hz();
    }
    else 
    {
      Output_1_Digital = false;
      Output_1_Duty = 0;
      Output_1_Mode = 0;
    }

    if(Output_1_Mode == 2)
    {
      if(CAN_Read_Msg[1]) EnableOutput1Digital();
      else DisableOutput1Digital();
    }

    if(Output_1_Mode == 1)
    {
      DisableOutput1Digital();
      if(CAN_Read_Msg[1] <= 100) Output_1_Duty = CAN_Read_Msg[1];
      else Output_1_Duty = 0;      
    }
  }

  if(CAN_Read_ID == (CAN_Base_Address + 8))
  {
    if(CAN_Read_Msg[0] == 0x01)
    {
      Output_2_Mode = 2;
    }
    else if (CAN_Read_Msg[0] == 0x02)
    {
      Output_2_Mode = 1;
      if(Output_2_PWMFreq != 10) SetupPWM10Hz();
    }

    else if (CAN_Read_Msg[0] == 0x04)
    {
      Output_2_Mode = 1;
      if(Output_2_PWMFreq != 50) SetupPWM50Hz();
    }

    else if (CAN_Read_Msg[0] == 0x08)
    {
      Output_2_Mode = 1;
      if(Output_2_PWMFreq != 100) SetupPWM100Hz();
    }
    else 
    {
      Output_2_Digital = false;
      Output_2_Duty = 0;
      Output_2_Mode = 0;
    }

    if(Output_2_Mode == 2)
    {
      if(CAN_Read_Msg[1]) EnableOutput2Digital();
      else DisableOutput2Digital();
    }

    if(Output_2_Mode == 1)
    {
      DisableOutput2Digital();
      if(CAN_Read_Msg[1] <= 100) Output_2_Duty = CAN_Read_Msg[1];
      else Output_2_Duty = 0;      
    }
  }

  if(CAN_Read_ID == (CAN_Base_Address + 9))
  {
    if(CAN_Read_Msg[0] == 0x01)
    {
      Output_3_Mode = 2;
    }
    else if (CAN_Read_Msg[0] == 0x02)
    {
      Output_3_Mode = 1;
      if(Output_3_PWMFreq != 10) SetupPWM10Hz();
    }

    else if (CAN_Read_Msg[0] == 0x04)
    {
      Output_3_Mode = 1;
      if(Output_3_PWMFreq != 50) SetupPWM50Hz();
    }

    else if (CAN_Read_Msg[0] == 0x08)
    {
      Output_3_Mode = 1;
      if(Output_3_PWMFreq != 100) SetupPWM100Hz();
    }
    else
    {
      Output_3_Digital = false;
      Output_3_Duty = 0;
      Output_3_Mode = 0;
    }

    if(Output_3_Mode == 2)
    {
      if(CAN_Read_Msg[1]) EnableOutput3Digital();
      else DisableOutput3Digital();
    }

    if(Output_3_Mode == 1)
    {
      DisableOutput3Digital();
      if(CAN_Read_Msg[1] <= 100) Output_3_Duty = CAN_Read_Msg[1];
      else Output_3_Duty = 0;      
    }
  }

  if(CAN_Read_ID == (CAN_Base_Address + 10))
  {
    if(CAN_Read_Msg[0] & 0x01) EnableCANTermResistor();
    else DisableCANTermResistor();

    if(CAN_Read_Msg[0] & 0x02) EnableGreenLED();
    else DisableGreenLED();

    if(CAN_Read_Msg[0] & 0x04) EnableRedLED();
    else DisableRedLED();
  }
}

That's a lot of code. I could maybe dig in there and figure out what you mean by "first pulse" and "second pulse" but figuring out what code does by reading is a pain. It would be a lot easier if you could explain what the code is meant to do and what pulses you mean. Point out the parts of the code you're talking about.

I would expect the see at least a variable that would count the pulses so you would know which is the current pulse.

It will be useful if you say exactly what sort of Arduino you are using. There is some weird stuff going on in that code.

do you mean here?

i am using a kaizen relay which has basically at its core a Arduino Leonard. and I am basically gibing is a controlled ignition input in position 3 and when. after receiving that input it will send a pulse out lasting half second, and then once it loses that ignition input it will send a second pulse out and the code is working all the way down to line 159 void loop_2 to line 171. 159 - 171 was added to add a one second delay to the first pulse after receiving the ignition input.

FQBN: arduino:avr:leonardo
Using board 'leonardo' from platform in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
Alternatives for KaizenRelay.h: [KaizenRelay_Template]
ResolveLibrary(KaizenRelay.h)
  -> candidates: [KaizenRelay_Template]
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
Alternatives for EEPROM.h: [EEPROM@2.0]
ResolveLibrary(EEPROM.h)
  -> candidates: [EEPROM@2.0]
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template\mcp_can.cpp -o nul
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src\SPI.cpp -o nul
Generating function prototypes...
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o C:\Users\skyle\AppData\Local\Temp\1042488695\sketch_merged.cpp
C:\Users\skyle\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\skyle\AppData\Local\Temp\1042488695\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Leonardo\"" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\leonardo" "-IC:\\Users\\skyle\\OneDrive\\Documents\\Arduino\\libraries\\KaizenRelay_Template" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\EEPROM\\src" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\SPI\\src" "C:\\Users\\skyle\\AppData\\Local\\Temp\\arduino\\sketches\\61C89FBC1236BEDDBC571678B000D3C2\\sketch\\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp" -o "C:\\Users\\skyle\\AppData\\Local\\Temp\\arduino\\sketches\\61C89FBC1236BEDDBC571678B000D3C2\\sketch\\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp.o"
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino: In function 'void loop()':
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:159:6: error: redefinition of 'void loop()'
 void loop() {
      ^~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:79:6: note: 'void loop()' previously defined here
 void loop()
      ^~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:161:19: error: 'Input1Digital' was not declared in this scope
   if (digitalRead(Input1Digital) == HIGH && !isInputHigh) {
                   ^~~~~~~~~~~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:161:19: note: suggested alternative: 'Input_1_Digital'
   if (digitalRead(Input1Digital) == HIGH && !isInputHigh) {
                   ^~~~~~~~~~~~~
                   Input_1_Digital
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:161:46: error: 'isInputHigh' was not declared in this scope
   if (digitalRead(Input1Digital) == HIGH && !isInputHigh) {
                                              ^~~~~~~~~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:164:18: error: 'Output1Digital' was not declared in this scope
     digitalWrite(Output1Digital, HIGH);
                  ^~~~~~~~~~~~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:164:18: note: suggested alternative: 'Output_1_Digital'
     digitalWrite(Output1Digital, HIGH);
                  ^~~~~~~~~~~~~~
                  Output_1_Digital
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:169:18: error: 'Output1Digital' was not declared in this scope
     digitalWrite(Output1Digital, LOW);
                  ^~~~~~~~~~~~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:169:18: note: suggested alternative: 'Output_1_Digital'
     digitalWrite(Output1Digital, LOW);
                  ^~~~~~~~~~~~~~
                  Output_1_Digital

Using library KaizenRelay_Template in folder: C:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template (legacy)
Using library EEPROM at version 2.0 in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM 
Using library SPI at version 1.0 in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI 
exit status 1

Compilation error: redefinition of 'void loop()'

How many loop() functions have you got in your code ? That includes loop() functions in code in multiple tabs in the IDE

Do you have a pin named Output1Digital or is it really named Output_1_Digital ?

i believe its output_1_digital and i have 2 loop functions in the code.

Do you think that might be the reason why

digitalWrite(Output1Digital, LOW);

causes an error ?

There is only one in the code that you posted. The other one is named loop_2() which is not the same thing at all, but how many tabs are open in the IDE ?

A two loops is allowed only on double-cored MCUs, but the Leonardo is a single-core board.

yes, i added loop_2 original code was just loop() instead of loop_2()

I am sorry to be pedantic by the loop() function is not the same as the loop_2() function

This error

Compilation error: redefinition of 'void loop()'

seems to indicate the there is more than one loop() function in your sketch or in the code in the tabs of the IDE or in library #included by your sketch

Please tell us how many tabs you have in the sketch that you are trying to compile


```cpp
//KaizenRelay Template
//Version 4.0 - 2022 January 22
//Kaizen Speed, LLC. - Vadim Belogorodsky

void EnableGreenLED();
void DisableGreenLED();

void EnableRedLED();
void DisableRedLED();

#include "KaizenRelay.h"

#define UseGenericCANRx 0               
#define UseGenericCANTx 0

//Program Variable Area:
bool InputState = false;
bool InputStateLast = false;
byte PulsePhase = 0;
bool PulseTimerRunning = false;
unsigned int PulseTimer = 0;

void setup() 
{
  //Setup Pins and CAN Timer:
  HardwareSetup();

  //Input Pin 1 Setup:
  //Enable5VSupply();
  //Disable5VSupply();
  //EnableInput1Pullup();
  //DisableInput1Pullup();
  EnableInput1Pulldown();
  //DisableInput1Pulldown();
  //DisableInput1Switches();

  //Input Pin 2 Setup:
  //EnableInput2Pullup();
  //DisableInput2Pullup();
  //EnableInput2Pulldown();
  //DisableInput2Pulldown();
  DisableInput2Switches();

  //Input Pin 3 Setup:
  //EnableInput3Pullup();
  //DisableInput3Pullup();
  //EnableInput3Pulldown();
  //DisableInput3Pulldown();
  DisableInput3Switches();
  
  //Output Pin 1 Setup:
  Output_1_Mode = 2;

  //Output Pin 2 Setup:
  Output_2_Mode = 2;

  //Output Pin 3 Setup:
  Output_3_Mode = 0;

  //Output PWM Setup:
  //SetupPWM10Hz();
  //SetupPWM50Hz();
  //SetupPWM100Hz();

  //CAN Baud Rate Setup:
  //SetupCAN_125kbps();
  //SetupCAN_250kbps();
  //SetupCAN_500kbps();
  //SetupCAN_1000kbps();
  
  //CAN Termination Resistor:
  //EnableCANTermResistor();
  DisableCANTermResistor();

  //Setup USB Interface
  Serial.begin(57600);
}

void loop() 
{
  //Check if CAN Messages are Available
  if(CAN_MSGAVAIL == CAN_.checkReceive())
  {
    //Read in CAN Message Length and Data
    CAN_.readMsgBuf(&CAN_Read_Len, CAN_Read_Msg);

    //Read in CAN Message ID
    CAN_Read_ID = CAN_.getCanId();

    //Generic CAN Listen
    if(UseGenericCANRx)
  	{
  		if((CAN_Read_ID >= CAN_Base_Address + 7) && (CAN_Read_ID <= CAN_Base_Address + 10)) 
  			CANListenMsg();
  	}
    CAN_MissedMsgs = 0;
  }
  else CAN_MissedMsgs++;

  CAN_Timeout = (CAN_MissedMsgs > 10000);

  //Variable Overflow Handle
  if(CAN_MissedMsgs > 60000) CAN_MissedMsgs = 11000;

  //Check if Serial Messages are Available()
  if(Serial.available())
  {    
    while(Serial.available()) 
    {
      SerialInput += (char)Serial.read();
    }

    SerialIndex = SerialInput.substring(0, 3);
    SerialData = SerialInput.substring(4, SerialInput.length());

    ReadHWStatusUSB();
    
    SerialInput = "";    
  }

  if(Flag10ms)
  {
    Timer10ms(); 
    Flag10ms = false;
  }

  if(Flag20ms && !Flag10ms)
  {
    Timer20ms(); 
    Flag20ms = false;
  }

  if(Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer50ms(); 
    Flag50ms = false;
  }
  
  if(Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer100ms(); 
    Flag100ms = false;
  }
  
  if(Flag500ms && !Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer500ms(); 
    Flag500ms = false;
  }

  if(Flag1000ms && !Flag500ms && !Flag100ms && !Flag50ms && !Flag20ms && !Flag10ms)
  {
    Timer1000ms(); 
    Flag1000ms = false;
  }
}

//This sets a timer delay for the output pin if voltage is suplied to the input and sets delay for the ouput once voltage is removed from the input.
void loop() {
  // Check if the input is high
  if (digitalRead(Input_1_Digital) == HIGH && !isInputHigh) {
    // Input is detected, wait one second and set output1 high 
    delay(1000);
    digitalWrite(Output_1_Digital, HIGH);
    isInputHigh = true;
  } else if (digitalRead(Input_1_Digital) == LOW && isInputHigh) {
    // Input is gone, wait 1 second and set output 1 low
    delay(1000);
    digitalWrite(Output_1_Digital, LOW);
    isInputHigh = false;
  }
}

void USB_Write()
{
  //User Area for USB Writing - Message Beginning "**"
  Serial.print("**");

  //Place Your Required Text Output Here -- for example:
  Serial.print("In: "); Serial.print(Input_1_Digital); 
  Serial.print(", Ph: "); Serial.print(PulsePhase);
  //Serial.print(", T_RunnRunning: "); Serial.print(PulseTimerRunning); 
  Serial.print(", Tmr: "); Serial.print(PulseTimer); 
  Serial.print(", Out: "); Serial.print(Output_1_Digital);
  
  //Message Ending ";"
  Serial.println(";");
} 
void Timer10ms()
{
  if(UseGenericCANTx) SendHWStatusCAN();

  Input_1_Digital = ReadInput1Digital(false);
  InputState = Input_1_Digital;
  if(InputState != InputStateLast)
  {
    if(!InputState) //On to Off
    {
      PulsePhase = 1;
      PulseTimer = 0;
      PulseTimerRunning = true;
    }

    if(InputState) //Off to On
    {
      PulsePhase = 2;
      PulseTimer = 0;
      PulseTimerRunning = true;
    }
  }
  InputStateLast = InputState;



  if(PulseTimerRunning) PulseTimer++;
  if(PulseTimer > 20000) PulseTimer = 10000;

  if(PulsePhase == 1)
  {
    if(PulseTimerRunning && (PulseTimer < 50)) {DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
    if(PulseTimerRunning && ((PulseTimer >= 50) && (PulseTimer < 100))) {EnableOutput1Digital(); DisableOutput2Digital(); EnableGreenLED();}
    if(PulseTimer == 100) {PulsePhase = 0; PulseTimerRunning = false; DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
  }

  if(PulsePhase == 2)
  {
    if(PulseTimerRunning && (PulseTimer <= 50)) {EnableOutput1Digital(); DisableOutput2Digital(); EnableGreenLED();}
    if(PulseTimer == 50) {PulsePhase = 0; PulseTimerRunning = false; DisableOutput1Digital(); EnableOutput2Digital(); DisableGreenLED();}
  }
}

void Timer20ms()
{
    USB_Write();
}

void Timer50ms()
{
  SendHWStatusUSB();
}

void Timer100ms()
{
  
}

void Timer500ms()
{
  
}

void Timer1000ms()
{
  //Generic CAN Listen
  if(UseGenericCANRx)
  {
    if(CAN_Timeout)
    {
      //CAN Error
      if(Output_1_Mode == 1) Output_1_Duty = 0; 
      if(Output_1_Mode == 2) DisableOutput1Digital(); 
      Output_1_Mode = 0; 
  
      if(Output_2_Mode == 1) Output_2_Duty = 0;
      if(Output_2_Mode == 2) DisableOutput2Digital();
      Output_2_Mode = 0; 
  
      if(Output_3_Mode == 1) Output_3_Duty = 0;
      if(Output_3_Mode == 2) DisableOutput3Digital();
      Output_3_Mode = 0; 
  
      DisableGreenLED();
      DisableRedLED();
    }  
  }
}



ISR(TIMER1_COMPA_vect) //Timer1 Interrupt 
{
  PWMpulseCounter++;
  if(PWMpulseCounter >= 99) PWMpulseCounter = 0;

  //Port Manipulation:
  
/*  
  //Green LED: PD1
  if(xxx)
  {
    if(PWMpulseCounter < Output_x_Duty) PORTD = PORTD | 0b00000010;
    else                                PORTD = PORTD & 0b11111101; 
  }

  //Red LED: PD0
  if(xxx)
  {
    if(PWMpulseCounter < Output_y_Duty) PORTD = PORTD | 0b00000001;
    else                                PORTD = PORTD & 0b11111110; 
  }

*/
  
  //Output 1: PB5
  if(Output_1_Mode == 1)
  {
    if(PWMpulseCounter < Output_1_Duty) PORTB = PORTB | 0b00100000;
    else                                PORTB = PORTB & 0b11011111; 
  }
  
  //Output 2: PC7
  if(Output_2_Mode == 1)
  {
    if(PWMpulseCounter < Output_2_Duty) PORTC = PORTC | 0b10000000;
    else                                PORTC = PORTC & 0b01111111;
  }
    
  //Output 3: PC6  
  if(Output_3_Mode == 1)
  {
    if(PWMpulseCounter < Output_3_Duty) PORTC = PORTC | 0b01000000;
    else                                PORTC = PORTC & 0b10111111;
  }
}

void CANListenMsg()
{
  if(CAN_Read_ID == (CAN_Base_Address + 7))
  {
    if(CAN_Read_Msg[0] == 0x01)
    {
      Output_1_Mode = 2;
    }
    else if (CAN_Read_Msg[0] == 0x02)
    {
      Output_1_Mode = 1;
      if(Output_1_PWMFreq != 10) SetupPWM10Hz();
    }

    else if (CAN_Read_Msg[0] == 0x04)
    {
      Output_1_Mode = 1;
      if(Output_1_PWMFreq != 50) SetupPWM50Hz();
    }

    else if (CAN_Read_Msg[0] == 0x08)
    {
      Output_1_Mode = 1;
      if(Output_1_PWMFreq != 100) SetupPWM100Hz();
    }
    else 
    {
      Output_1_Digital = false;
      Output_1_Duty = 0;
      Output_1_Mode = 0;
    }

    if(Output_1_Mode == 2)
    {
      if(CAN_Read_Msg[1]) EnableOutput1Digital();
      else DisableOutput1Digital();
    }

    if(Output_1_Mode == 1)
    {
      DisableOutput1Digital();
      if(CAN_Read_Msg[1] <= 100) Output_1_Duty = CAN_Read_Msg[1];
      else Output_1_Duty = 0;      
    }
  }

  if(CAN_Read_ID == (CAN_Base_Address + 8))
  {
    if(CAN_Read_Msg[0] == 0x01)
    {
      Output_2_Mode = 2;
    }
    else if (CAN_Read_Msg[0] == 0x02)
    {
      Output_2_Mode = 1;
      if(Output_2_PWMFreq != 10) SetupPWM10Hz();
    }

    else if (CAN_Read_Msg[0] == 0x04)
    {
      Output_2_Mode = 1;
      if(Output_2_PWMFreq != 50) SetupPWM50Hz();
    }

    else if (CAN_Read_Msg[0] == 0x08)
    {
      Output_2_Mode = 1;
      if(Output_2_PWMFreq != 100) SetupPWM100Hz();
    }
    else 
    {
      Output_2_Digital = false;
      Output_2_Duty = 0;
      Output_2_Mode = 0;
    }

    if(Output_2_Mode == 2)
    {
      if(CAN_Read_Msg[1]) EnableOutput2Digital();
      else DisableOutput2Digital();
    }

    if(Output_2_Mode == 1)
    {
      DisableOutput2Digital();
      if(CAN_Read_Msg[1] <= 100) Output_2_Duty = CAN_Read_Msg[1];
      else Output_2_Duty = 0;      
    }
  }

  if(CAN_Read_ID == (CAN_Base_Address + 9))
  {
    if(CAN_Read_Msg[0] == 0x01)
    {
      Output_3_Mode = 2;
    }
    else if (CAN_Read_Msg[0] == 0x02)
    {
      Output_3_Mode = 1;
      if(Output_3_PWMFreq != 10) SetupPWM10Hz();
    }

    else if (CAN_Read_Msg[0] == 0x04)
    {
      Output_3_Mode = 1;
      if(Output_3_PWMFreq != 50) SetupPWM50Hz();
    }

    else if (CAN_Read_Msg[0] == 0x08)
    {
      Output_3_Mode = 1;
      if(Output_3_PWMFreq != 100) SetupPWM100Hz();
    }
    else
    {
      Output_3_Digital = false;
      Output_3_Duty = 0;
      Output_3_Mode = 0;
    }

    if(Output_3_Mode == 2)
    {
      if(CAN_Read_Msg[1]) EnableOutput3Digital();
      else DisableOutput3Digital();
    }

    if(Output_3_Mode == 1)
    {
      DisableOutput3Digital();
      if(CAN_Read_Msg[1] <= 100) Output_3_Duty = CAN_Read_Msg[1];
      else Output_3_Duty = 0;      
    }
  }

  if(CAN_Read_ID == (CAN_Base_Address + 10))
  {
    if(CAN_Read_Msg[0] & 0x01) EnableCANTermResistor();
    else DisableCANTermResistor();

    if(CAN_Read_Msg[0] & 0x02) EnableGreenLED();
    else DisableGreenLED();

    if(CAN_Read_Msg[0] & 0x04) EnableRedLED();
    else DisableRedLED();
  }
}

The sketch that you just posted does have 2 loop() functions in it. That is not allowed

this is my new error codes and above is an updated version with updated Output_1_digital

FQBN: arduino:avr:leonardo
Using board 'leonardo' from platform in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
Alternatives for KaizenRelay.h: [KaizenRelay_Template]
ResolveLibrary(KaizenRelay.h)
  -> candidates: [KaizenRelay_Template]
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
Alternatives for EEPROM.h: [EEPROM@2.0]
ResolveLibrary(EEPROM.h)
  -> candidates: [EEPROM@2.0]
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o nul
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template\mcp_can.cpp -o nul
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src\SPI.cpp -o nul
Generating function prototypes...
C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src -IC:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\skyle\AppData\Local\Temp\arduino\sketches\61C89FBC1236BEDDBC571678B000D3C2\sketch\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp -o C:\Users\skyle\AppData\Local\Temp\3761822484\sketch_merged.cpp
C:\Users\skyle\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\skyle\AppData\Local\Temp\3761822484\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Leonardo\"" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\leonardo" "-IC:\\Users\\skyle\\OneDrive\\Documents\\Arduino\\libraries\\KaizenRelay_Template" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\EEPROM\\src" "-IC:\\Users\\skyle\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\SPI\\src" "C:\\Users\\skyle\\AppData\\Local\\Temp\\arduino\\sketches\\61C89FBC1236BEDDBC571678B000D3C2\\sketch\\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp" -o "C:\\Users\\skyle\\AppData\\Local\\Temp\\arduino\\sketches\\61C89FBC1236BEDDBC571678B000D3C2\\sketch\\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino.cpp.o"
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino: In function 'void loop()':
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:159:6: error: redefinition of 'void loop()'
 void loop() {
      ^~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:79:6: note: 'void loop()' previously defined here
 void loop()
      ^~~~
C:\Users\skyle\OneDrive\Documents\kaizen relay software\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024\kaizenRelay_Main_software_with_output_timer_MR_1_13_2024.ino:161:48: error: 'isInputHigh' was not declared in this scope
   if (digitalRead(Input_1_Digital) == HIGH && !isInputHigh) {
                                                ^~~~~~~~~~~

Using library KaizenRelay_Template in folder: C:\Users\skyle\OneDrive\Documents\Arduino\libraries\KaizenRelay_Template (legacy)
Using library EEPROM at version 2.0 in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM 
Using library SPI at version 1.0 in folder: C:\Users\skyle\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI 
exit status 1

Compilation error: redefinition of 'void loop()'

Do you actually read the error messages ?

error: 'isInputHigh' was not declared in this scope

The compiler is not mistaken. Where is isInputHigh declared ?

there are nothing new in the error:

You are not allowed to use a multiple loop() functions in the code.

Where did you get this code?
It seems that you know very little about programming, so what is purpose to modify this code for you?