Trailor Light Programming issues...

Hello. I have recently been working on a project that includes creating a working model of trailor light sequences with three push button inputs. I have an arduino uno and plan to change it over to an arduino mega 2560. My plan is to have three inputs (switches/buttons): LeftSwitch, RightSwitch, BrakeSwitch.

I have gotten the program to work before I added the extra pieces that make the Right blinker and right brake light go steady while the left blinker is flashing for inputs --> LeftSwitch and BrakeSwitch are applied. This is the same for the RightSwitch and BrakeSwitch are applied, but just reveresed. Anyways what I would Like help with is fixing my code to make it comply-able.

This is my code below, I have many errors popping up but I am not sure what they mean...

//A sketch to control the indicator light of a vehicle, including right, left blinker and brake light.


const int Hazards = 9;
const int BrakeSwitch = 3;
const int BrakeLightL = 7;
const int BrakeLightR = 8
const int RightSwitch = 4;
const int RightBlink = 6;
const int LeftSwitch = 2;
const int LeftBlink = 5;


int BrakeSwitchVal = 0; //Monitors the value of the Brake switch, whether 1 or 0 (HIGH or LOW). Initially set at 0(LOW)
int previousBrakeSwitchVal = 0; //Monitors the value of the Brake switch from last time it was checked. Initally set at 0(LOW)

long RightSwitchMillis = 0; //Time stamp for when the switch last went to 1(HIGH). Initially set at 0(LOW)
int RightSwitchVal = 0; //Monitors the value of the Right Blinker switch, whether 1 or 0 (HIGH or LOW). Initially set at 0(LOW)
int previousRightSwitchVal = 0; //Monitors the value of the Right Blinker switch from last time it was checked. Initally set at 0(LOW)
int RightBlinkState = LOW; //State of the Right Blinker Light. Initally set to LOW(Off)
long RightFlashMillis = 0; //Time stamp for when rapid flash last went to 1(LOW), initially set at O(LOW)
long LeftSwitchMillis = 0;

int LeftSwitchVal = 0;
int previousLeftSwitchVal = 0;
int LeftBlinkState = LOW;
long LeftFlashMillis = 0;

long interval = 1000; // interval at which to blink (milliseconds)

  


void setup() 
{
  pinMode(BrakeLightL, OUTPUT); 
  pinMode(BrakeLightR, OUTPUT); 
  pinMode(BrakeSwitch, INPUT);
  
  pinMode(RightBlink, OUTPUT); 
  pinMode(RightSwitch, INPUT); 
  
  pinMode(LeftBlink, OUTPUT); 
  pinMode(LeftSwitch, INPUT); 
}



void loop()
{
  unsigned long currentMillis = millis(); //initiallizes the clock 
  
  
  
//Brake Light Code////////////////////////////////////////////////////////////////////////////////////////
BrakeSwitchVal = digitalRead(BrakeSwitch); //read and store brake switch status
  if ((BrakeSwitchVal == HIGH) && (previousBrakeSwitchVal == LOW)) //compares current switch status to previous status
   {
    previousBrakeSwitchVal = BrakeSwitchVal; //sets the current status as the old status in preparation for the next check
   }
       if ((BrakeSwitchVal == HIGH)) //checks if the brake switch is pressed and how long it has been pressed for
         {
         digitalWrite ((BrakeLightL, HIGH) && (BrakeLightR, HIGH)); //if the switch is being pressed on and it has been pressed for longer than one half second, the brake light goes on full and steady.
         }
         
        if (BrakeSwitchVal == LOW)
         {
           previousBrakeSwitchVal = BrakeSwitchVal; //makes sure the previousBrakeSwitch value is reset of off when the switch is in fact off.
           digitalWrite ((BrakeLightL, LOW) && (BrakeLightR, LOW)); //Overall, if the brake switch is off, keep the brake lights off.   
         }


//Right Blinker Code/////////////////////////////////////////////////////////////////////////////////////////////////////////
  RightSwitchVal = digitalRead(RightSwitch); //read and store Right Blinker switch status
  
  if ((RightSwitchVal == HIGH) && (previousRightSwitchVal == LOW)) //compares current switch status to previous status
    {
     previousRightSwitchVal = RightSwitchVal; //sets the current status as the old status in preparation for the next check
     RightSwitchMillis = currentMillis; //sets a time stamp at the current time
    }

    if((RightSwitchVal == HIGH) && (currentMillis - RightFlashMillis > interval/4)) //if the Right Blink switch is HIGH but less than half a second has elapsed,                                                                                                                                 
         {                                                                                                                                 // this checks if the Right Blink switch is HIGH and more than one-fifteith
        RightFlashMillis = currentMillis; // saves current time                                                                             //of a second has elapsed since the last time previousMillis10 was reset.
         
         if (RightBlinkState == LOW)
            RightBlinkState = HIGH;
          else
            RightBlinkState = LOW; //if more than one-fiftieth of a second has elapsed since the time stamp was reset, reverse the state of the Right Blinker.
            
          digitalWrite(RightBlink, RightBlinkState); // set the Right Blinker with the state of the variable:
          }
     
          
    if (RightSwitchVal == LOW) //checks if the Blinker switch is still on or not. If it is off, the following occurs...
         {
           previousRightSwitchVal = RightSwitchVal; //makes sure the previousBrakeSwitch value is reset to off when the switch is in fact off.
           RightBlinkState = LOW; //resets the blinker
           digitalWrite(RightBlink, RightBlinkState); //Overall, if the Right Blinker switch is off, keep the Right Blinker off. 
         }
         
 //Left Blinker Code. Identical to Right Blinker Code.//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  LeftSwitchVal = digitalRead(LeftSwitch);
  
  if ((LeftSwitchVal == HIGH) && (previousLeftSwitchVal == LOW))
    {
     previousLeftSwitchVal = LeftSwitchVal;
     LeftSwitchMillis = currentMillis;
    }


    if((LeftSwitchVal == HIGH) && (currentMillis - LeftFlashMillis > interval/4))                                                                                                                                 
         {
        LeftFlashMillis = currentMillis;//sets time stamp//
         
         if (LeftBlinkState == LOW)
            LeftBlinkState = HIGH;
          else
            LeftBlinkState = LOW;
            
          digitalWrite(LeftBlink, LeftBlinkState);
          }
     
          
    if (LeftSwitchVal == LOW)
         {
           previousLeftSwitchVal = LeftSwitchVal;
           LeftBlinkState = LOW;
           digitalWrite(LeftBlink, LeftBlinkState);
         }

Post the errors
Ctrl+t to format the code in the IDE
Add missing } to end of loop()

Here is the second part that I added…

//Left blinker and brakes applied//
        
 LeftSwitchVal = digitalRead(LeftSwitch);
 BrakeSwitchVal = digitalRead(BrakeSwitch);
 if ((LeftSwitchVal == HIGH) && (BrakeSwitchVal == HIGH));
       {
         LeftFlashMillis = currentMillis; //sets time stamp//
         previousBrakeSwitchVal = BrakeSwitchVal;
         previousLeftSwitchVal = LeftSwitchVal;
         
        digitalWrite ((BrakeLightR, HIGH) && (RightBlink, HIGH));
        digitalWrite (LeftBlinkState = HIGH);    //If left switch and brake switch is applied, then make the right brake light and the right blink light go steady on while the left blinker flashes.
        
        else 
        LeftBlinkState = LOW;
           
         digitalWrite(LeftBlink, LeftBlinkState);
        
        
     if (BrakeSwitchVal == LOW)
        {
          previousBrakeSwitchVal = BrakeSwitchVal; //makes sure the previousBrakeSwitch value is reset of off when the switch is in fact off.
          digitalWrite ((RightBlink, LOW) && (BrakeLightR, LOW)); //Overall, if the brake switch is off, keep the brake light and right blink brake light off.
        }

     }
     
       RightSwitchVal = digitalRead(RightSwitch);
 BrakeSwitchVal = digitalRead(BrakeSwitch);
 if ((RightSwitchVal == HIGH) && (BrakeSwitchVal == HIGH));
       {
         RightFlashMillis = currentMillis; //sets time stamp//
         previousBrakeSwitchVal = BrakeSwitchVal;
         previousRightSwitchVal = RightSwitchVal;
         
        digitalWrite ((BrakeLightL, HIGH) && (LeftBlink, HIGH));
        digitalWrite (RightBlinkState = HIGH);    //If Right switch and brake switch is applied, then make the Left brake light and the Left blink light go steady on while the Right blinker flashes.
        
        else 
        RightBlinkState = LOW;
           
         digitalWrite(RightBlink, RightBlinkState);
        
        
     if (BrakeSwitchVal == LOW)
        {
          previousBrakeSwitchVal = BrakeSwitchVal; //makes sure the previousBrakeSwitch value is reset of off when the switch is in fact off.
          digitalWrite ((RightBlink, LOW) && (BrakeLightL, LOW)); //Overall, if the brake switch is off, keep the brake light and Left blink brake light off.
        }
        
       }

Here are the errors…

sketch_dec23a.ino:8:1: error: expected ‘,’ or ‘;’ before ‘const’
sketch_dec23a.ino: In function ‘void setup()’:
sketch_dec23a.ino:41:11: error: ‘RightSwitch’ was not declared in this scope
sketch_dec23a.ino: In function ‘void loop()’:
sketch_dec23a.ino:63:61: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:69:59: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:74:32: error: ‘RightSwitch’ was not declared in this scope
sketch_dec23a.ino:143:60: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:144:40: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:146:5: error: ‘else’ without a previous ‘if’
sketch_dec23a.ino:155:60: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:168:59: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:169:41: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
sketch_dec23a.ino:171:5: error: ‘else’ without a previous ‘if’
sketch_dec23a.ino:180:60: error: too few arguments to function ‘void digitalWrite(uint8_t, uint8_t)’
In file included from sketch_dec23a.ino:4:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:99:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^

const int BrakeLightR = 8

Missing ;

        digitalWrite (LeftBlinkState = HIGH);    //If left switch and brake switch is applied, then make the right brake light and the right blink light go steady on while the left blinker flashes.

Which pin are you writing to here? You repeat this error many times in different ways. Note that this also has the side-effect of CHANGING LeftBlinkState to HIGH, no matter what it was before. You probably meant to use the == operator.

You can assume HIGH is true, so ==HIGH is redundant anyway. if(a==HIGH) is the same as if(a)

too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'

It's small but, notice that the compiler is telling you it wants to see TWO arguments separated by a comma inside the parentheses. Your statements don't have a comma so, only one argument.

Forgot running lights (headlight switch)

Reverse lights?

-jim lee

jimLee:
Reverse lights?

On a trailer ? to see the trailer itself while reversing and making it go the way you want is one, thing, but to look beyond the trailer is something which is beyond most people, trust me, I'm a professional driver.

Some countries put reverse lights on trailers. Some countries don't require it. Just as some don't require independent bulbs for turn signals and brake lights.