A little stumped with analog input behaviour on a MEGA2560

Hello There,

I'm working with on a little PowerWheels project for my kids and I've added a variable throttle as well as indicator lights.

My indicator lights code works perfectly when running it in its own sketch and so does the throttle AI input code.

However, when I merge the two sketches, then reading the analog input seems to trigger the right indicator digitalRead variable to read HIGH without the switch being turned on which doesn't make sense.

I've used a my multimeter and tested for short circuits between these pins, between the pins and ground as well as between the pins to +5Vand there are no short circuits which leads me to believe that the behaviour comes from a problem with my programming.

The result of this is that the right indicator light starts to flash without the switch being turned on.

I also confirmed this, with commenting out the analogRead line which seems to resolve the problem and hence the reason why I am a little bit stumped here.

I've uploaded a zip file since I've coded it using two sketches in a single folder.

Pin definitions are:
Throttle input: A2
Left indicator input: 32
right indicator input 33

I'm hoping for some insights here as I cannot seem to figure this one out. Thank you in advance.

Wiring:

01_Throttle_Control.zip (3.0 KB)

Please post code.

The code is in the zip file. The code consists of two sketches which are combined which is why I opted to zip the code.

I attached the individual sketches in case zip files are a concern.

01_Throttle_Control.ino (9.3 KB)
02_Switch_Indicator_Code.ino (2.5 KB)

And I'm posting from my phone.

Your move.

Hey there,

Sorry about that, and I appreciate you looking at this from your phone.

Sketch 1:


//  Speed Control Variables
//  ************************
#define Throttle_AI_Pin A2
unsigned int Throttle_Pedal_Input = 0;
unsigned int Remapped_Throttle_Pedal_Input = 0;

//  Throttle Min and Max AI generated, this needs to be checked and changed with each different unit for proper scaling purposes.
//  ******************************************************************************************************************************
unsigned int Throttle_Pedal_AI_Min = 150;  //190
unsigned int Throttle_Pedal_AI_Max = 850; // 670 Actual value is ~ 870, but the pedal have to be compressed all the way to achieve this, as an alterantive I'm making it so that the max is more easily achieved.

byte Throttle_Pedal_AI_Min_Low_Throttle_Cut_Off = 70;  // Value used to set the throttle zero point to zero. There are some drift around the zero point and this helps to remove the drift.
byte Throttle_Pedal_AI_Premature_Max_Initiator = 50;  // Value used to set the throttle zero point to zero. There are some drift around the zero point and this helps to remove the drift.

unsigned int Throttle_Pedal_Remapped_Min = 0;
unsigned int Throttle_Pedal_Remapped_Max = 700;
unsigned int Reverse_Throttle_Max = Throttle_Pedal_Remapped_Max / 2;;
unsigned int Governor_Max = Throttle_Pedal_Remapped_Max; // To be defined and stored in the EEPROM and to be remotely configured via remote.

//  Braking Pins & Variables
//  *************************
byte ESC_Brake_DO_Pin = 6;
byte ESC_Brake_Threshold = 10; // min. speed prior to ESC breaking being initiated.
byte ESC_Brake_Latch = 0;
byte ESC_Brake_Hysteresis = 5; //Brake hysteresis to prevent toggling

//  Averaged Accelleration Variables
//  **********************************
byte Averaged_Throttle = 0;
byte Averaged_Throttle_Array[20];       // Array used for the averaging of the acceleration
byte Throttle_Array_Indexer = 0;
unsigned long Acc_Buffer_Update = 0;    // Timestamp for averaged acceleration
unsigned long Acc_Buffer_Period = 500;  //  Update rate for the average acceleration function, decrease this for a faster averaging update which in turn will result in faster accelaration.
byte Deceleration_Theshold = 50;

//  Indicator Lights Varialbes
//  **************************

#define Left_Indicator_Lights_DI_Pin 32
#define Right_Indicator_Lights_DI_Pin 33
#define Left_Indicator_Lights_DO_Pin 35
#define Right_Indicator_Lights_DO_Pin 34

int Left_Indicator_Lights_State = LOW;
int Left_Indicator_Input_State = LOW;
int Right_Indicator_Lights_State = LOW;
int Right_Indicator_Input_State = LOW;

unsigned long Previous_Millis = 0;        // will store last time LED was updated
unsigned long Current_Millis;
const long Timer_Interval = 400;           // interval at which to blink (milliseconds)

byte Left_Indicator;
byte Right_Indicator;

// Debugging Variables
// *******************

int Second_Check_Time = 1000;
long Prev_Second_Check_Time;

//  *************************************************

void setup()
{
  pinMode(Throttle_AI_Pin, INPUT);

  pinMode(Left_Indicator_Lights_DI_Pin, INPUT);
  pinMode(Right_Indicator_Lights_DI_Pin, INPUT);
  pinMode(Left_Indicator_Lights_DO_Pin, OUTPUT);  
  pinMode(Right_Indicator_Lights_DO_Pin, OUTPUT);
    
  Serial.begin(250000);
  while (!Serial) 
  { 
  ;
  }  
}

void loop()
{

  Throttle_Pedal_Input = analogRead(Throttle_AI_Pin);
  Left_Indicator_Input_State = digitalRead(Left_Indicator_Lights_DI_Pin);
  Right_Indicator_Input_State = digitalRead(Right_Indicator_Lights_DI_Pin);
  
  Throttle_Control();
  Delayed_Acceleration();
  Braking_Function();

  Indicator_Function();

  Debugging();

}

/**************************************************************************************************************************************************************************
**************************************************                       Brake Application Logic                        ***************************************************
**************************************************************************************************************************************************************************/

void Throttle_Control()
{


  if (Throttle_Pedal_Input <= Throttle_Pedal_AI_Min + Throttle_Pedal_AI_Min_Low_Throttle_Cut_Off) //  Forces the input to a min value if the input is lower than input + min cut off value, this eliminates drift around the 0.
  {
    Throttle_Pedal_Input = Throttle_Pedal_AI_Min;
  }

  if (Throttle_Pedal_Input >= Throttle_Pedal_AI_Max - Throttle_Pedal_AI_Premature_Max_Initiator) // Forces the input to the max value without the need to compress the throttle all the way down and at the same time it limits the throttle.
  {
    Throttle_Pedal_Input = Throttle_Pedal_AI_Max;
  }

  Remapped_Throttle_Pedal_Input = map(Throttle_Pedal_Input, Throttle_Pedal_AI_Min, Throttle_Pedal_AI_Max, Throttle_Pedal_Remapped_Min, Throttle_Pedal_Remapped_Max );   //  Remapping of the input to a 0 - 700 range
  
  if (Remapped_Throttle_Pedal_Input > Governor_Max)     // Ignore values above the govener max
  {
    Remapped_Throttle_Pedal_Input = Governor_Max;
  }
}

/**************************************************************************************************************************************************************************
**************************************************                       Brake Application Logic                        ***************************************************
**************************************************************************************************************************************************************************/

void Braking_Function()
{
  if ((Remapped_Throttle_Pedal_Input < ESC_Brake_Threshold) & ESC_Brake_Latch == 0) // Apply braking
  {
    digitalWrite(ESC_Brake_DO_Pin, HIGH);
    ESC_Brake_Latch = 1;
  }

  if ((Remapped_Throttle_Pedal_Input > (ESC_Brake_Threshold + ESC_Brake_Hysteresis)) & ESC_Brake_Latch == 1) // Remove braking
  {
    digitalWrite(ESC_Brake_DO_Pin, LOW);
    ESC_Brake_Latch = 0;
  }
}

/**************************************************************************************************************************************************************************
**************************************************                        Delayed Accelertaion                          ***************************************************
**************************************************************************************************************************************************************************/

void Delayed_Acceleration()
{
  if (millis() - Acc_Buffer_Update >= Acc_Buffer_Period) // Begin throttle acceleration control
  {
    //Test to see whether the throttle increased
    if (Remapped_Throttle_Pedal_Input > Averaged_Throttle) // if acceleration is detected then utilize the floating average. Note this compares the average and no specific value
    {
      Acc_Buffer_Update = millis();
      Averaged_Throttle_Array[Throttle_Array_Indexer] = Remapped_Throttle_Pedal_Input;
      Throttle_Array_Indexer++;

      if (Throttle_Array_Indexer > 19)
      {
        Throttle_Array_Indexer = 0;
      }

      int sum = 0;

      for (byte b = 0; b <= 19; b++)
      {
        sum = sum + Averaged_Throttle_Array[b];
      }

      Averaged_Throttle = sum / 20;
    }

    //Test to see whether the throttle decreased
    if (Remapped_Throttle_Pedal_Input < (Averaged_Throttle - Deceleration_Theshold)) //If throttle has decreased then the entire array gets the new leeser value for instant deceleration
    {
      for (byte b = 0; b <= 19; b++)
      {
        Averaged_Throttle_Array[b] = Remapped_Throttle_Pedal_Input;
      }

      Averaged_Throttle = Remapped_Throttle_Pedal_Input;
    }
  }
}


/**************************************************************************************************************************************************************************
**************************************************                            Debugging                                 ***************************************************
**************************************************************************************************************************************************************************/

void Debugging()
{
   //***********************************************************************

  if(millis() - Second_Check_Time > Prev_Second_Check_Time)
  {     
    Serial.print("Remapped Throttle:");
    Serial.print("\t\t");
    Serial.print(Remapped_Throttle_Pedal_Input);
    Serial.print('\n'); 
    
    Serial.print("Left Indicator Input State:");
    Serial.print("\t");
    Serial.print(Left_Indicator_Input_State);
    Serial.print('\n');  
    
    Serial.print("Right Indicator Input State:");
    Serial.print("\t");
    Serial.print(Right_Indicator_Input_State);
    Serial.print('\n'); 
    
    //***********************************************************************
    
    Serial.print('\n'); 
    Serial.print('\n'); 
    
    Prev_Second_Check_Time = millis();
  }

  //***********************************************************************

}

//*************************************************************************************************************************************************************************

Sketch 2:


//  Speed Control Variables
//  ************************
#define Throttle_AI_Pin A2
unsigned int Throttle_Pedal_Input = 0;
unsigned int Remapped_Throttle_Pedal_Input = 0;

//  Throttle Min and Max AI generated, this needs to be checked and changed with each different unit for proper scaling purposes.
//  ******************************************************************************************************************************
unsigned int Throttle_Pedal_AI_Min = 150;  //190
unsigned int Throttle_Pedal_AI_Max = 850; // 670 Actual value is ~ 870, but the pedal have to be compressed all the way to achieve this, as an alterantive I'm making it so that the max is more easily achieved.

byte Throttle_Pedal_AI_Min_Low_Throttle_Cut_Off = 70;  // Value used to set the throttle zero point to zero. There are some drift around the zero point and this helps to remove the drift.
byte Throttle_Pedal_AI_Premature_Max_Initiator = 50;  // Value used to set the throttle zero point to zero. There are some drift around the zero point and this helps to remove the drift.

unsigned int Throttle_Pedal_Remapped_Min = 0;
unsigned int Throttle_Pedal_Remapped_Max = 700;
unsigned int Reverse_Throttle_Max = Throttle_Pedal_Remapped_Max / 2;;
unsigned int Governor_Max = Throttle_Pedal_Remapped_Max; // To be defined and stored in the EEPROM and to be remotely configured via remote.

//  Braking Pins & Variables
//  *************************
byte ESC_Brake_DO_Pin = 6;
byte ESC_Brake_Threshold = 10; // min. speed prior to ESC breaking being initiated.
byte ESC_Brake_Latch = 0;
byte ESC_Brake_Hysteresis = 5; //Brake hysteresis to prevent toggling

//  Averaged Accelleration Variables
//  **********************************
byte Averaged_Throttle = 0;
byte Averaged_Throttle_Array[20];       // Array used for the averaging of the acceleration
byte Throttle_Array_Indexer = 0;
unsigned long Acc_Buffer_Update = 0;    // Timestamp for averaged acceleration
unsigned long Acc_Buffer_Period = 500;  //  Update rate for the average acceleration function, decrease this for a faster averaging update which in turn will result in faster accelaration.
byte Deceleration_Theshold = 50;

//  Indicator Lights Varialbes
//  **************************

#define Left_Indicator_Lights_DI_Pin 32
#define Right_Indicator_Lights_DI_Pin 33
#define Left_Indicator_Lights_DO_Pin 35
#define Right_Indicator_Lights_DO_Pin 34

int Left_Indicator_Lights_State = LOW;
int Left_Indicator_Input_State = LOW;
int Right_Indicator_Lights_State = LOW;
int Right_Indicator_Input_State = LOW;

unsigned long Previous_Millis = 0;        // will store last time LED was updated
unsigned long Current_Millis;
const long Timer_Interval = 400;           // interval at which to blink (milliseconds)

byte Left_Indicator;
byte Right_Indicator;

// Debugging Variables
// *******************

int Second_Check_Time = 1000;
long Prev_Second_Check_Time;

//  *************************************************

void setup()
{
  pinMode(Throttle_AI_Pin, INPUT);

  pinMode(Left_Indicator_Lights_DI_Pin, INPUT);
  pinMode(Right_Indicator_Lights_DI_Pin, INPUT);
  pinMode(Left_Indicator_Lights_DO_Pin, OUTPUT);  
  pinMode(Right_Indicator_Lights_DO_Pin, OUTPUT);
    
  Serial.begin(250000);
  while (!Serial) 
  { 
  ;
  }  
}

void loop()
{

  Throttle_Pedal_Input = analogRead(Throttle_AI_Pin);
  Left_Indicator_Input_State = digitalRead(Left_Indicator_Lights_DI_Pin);
  Right_Indicator_Input_State = digitalRead(Right_Indicator_Lights_DI_Pin);
  
  Throttle_Control();
  Delayed_Acceleration();
  Braking_Function();

  Indicator_Function();

  Debugging();

}

/**************************************************************************************************************************************************************************
**************************************************                       Brake Application Logic                        ***************************************************
**************************************************************************************************************************************************************************/

void Throttle_Control()
{


  if (Throttle_Pedal_Input <= Throttle_Pedal_AI_Min + Throttle_Pedal_AI_Min_Low_Throttle_Cut_Off) //  Forces the input to a min value if the input is lower than input + min cut off value, this eliminates drift around the 0.
  {
    Throttle_Pedal_Input = Throttle_Pedal_AI_Min;
  }

  if (Throttle_Pedal_Input >= Throttle_Pedal_AI_Max - Throttle_Pedal_AI_Premature_Max_Initiator) // Forces the input to the max value without the need to compress the throttle all the way down and at the same time it limits the throttle.
  {
    Throttle_Pedal_Input = Throttle_Pedal_AI_Max;
  }

  Remapped_Throttle_Pedal_Input = map(Throttle_Pedal_Input, Throttle_Pedal_AI_Min, Throttle_Pedal_AI_Max, Throttle_Pedal_Remapped_Min, Throttle_Pedal_Remapped_Max );   //  Remapping of the input to a 0 - 700 range
  
  if (Remapped_Throttle_Pedal_Input > Governor_Max)     // Ignore values above the govener max
  {
    Remapped_Throttle_Pedal_Input = Governor_Max;
  }
}

/**************************************************************************************************************************************************************************
**************************************************                       Brake Application Logic                        ***************************************************
**************************************************************************************************************************************************************************/

void Braking_Function()
{
  if ((Remapped_Throttle_Pedal_Input < ESC_Brake_Threshold) & ESC_Brake_Latch == 0) // Apply braking
  {
    digitalWrite(ESC_Brake_DO_Pin, HIGH);
    ESC_Brake_Latch = 1;
  }

  if ((Remapped_Throttle_Pedal_Input > (ESC_Brake_Threshold + ESC_Brake_Hysteresis)) & ESC_Brake_Latch == 1) // Remove braking
  {
    digitalWrite(ESC_Brake_DO_Pin, LOW);
    ESC_Brake_Latch = 0;
  }
}

/**************************************************************************************************************************************************************************
**************************************************                        Delayed Accelertaion                          ***************************************************
**************************************************************************************************************************************************************************/

void Delayed_Acceleration()
{
  if (millis() - Acc_Buffer_Update >= Acc_Buffer_Period) // Begin throttle acceleration control
  {
    //Test to see whether the throttle increased
    if (Remapped_Throttle_Pedal_Input > Averaged_Throttle) // if acceleration is detected then utilize the floating average. Note this compares the average and no specific value
    {
      Acc_Buffer_Update = millis();
      Averaged_Throttle_Array[Throttle_Array_Indexer] = Remapped_Throttle_Pedal_Input;
      Throttle_Array_Indexer++;

      if (Throttle_Array_Indexer > 19)
      {
        Throttle_Array_Indexer = 0;
      }

      int sum = 0;

      for (byte b = 0; b <= 19; b++)
      {
        sum = sum + Averaged_Throttle_Array[b];
      }

      Averaged_Throttle = sum / 20;
    }

    //Test to see whether the throttle decreased
    if (Remapped_Throttle_Pedal_Input < (Averaged_Throttle - Deceleration_Theshold)) //If throttle has decreased then the entire array gets the new leeser value for instant deceleration
    {
      for (byte b = 0; b <= 19; b++)
      {
        Averaged_Throttle_Array[b] = Remapped_Throttle_Pedal_Input;
      }

      Averaged_Throttle = Remapped_Throttle_Pedal_Input;
    }
  }
}


/**************************************************************************************************************************************************************************
**************************************************                            Debugging                                 ***************************************************
**************************************************************************************************************************************************************************/

void Debugging()
{
   //***********************************************************************

  if(millis() - Second_Check_Time > Prev_Second_Check_Time)
  {     
    Serial.print("Remapped Throttle:");
    Serial.print("\t\t");
    Serial.print(Remapped_Throttle_Pedal_Input);
    Serial.print('\n'); 
    
    Serial.print("Left Indicator Input State:");
    Serial.print("\t");
    Serial.print(Left_Indicator_Input_State);
    Serial.print('\n');  
    
    Serial.print("Right Indicator Input State:");
    Serial.print("\t");
    Serial.print(Right_Indicator_Input_State);
    Serial.print('\n'); 
    
    //***********************************************************************
    
    Serial.print('\n'); 
    Serial.print('\n'); 
    
    Prev_Second_Check_Time = millis();
  }

  //***********************************************************************

}

//*************************************************************************************************************************************************************************

i combined you files and they seemed to run correctly on an Uno.
i mapped the pins to ones i have access to on an Uno, but since i don't have pull-down resistors, i configured the input pins as INPUT_PULLUP.

each pin was read as a one without being pressed. when pressed, each causes one of the output (LEDs) to toggle on/off

presumably your observations are based on what your Debugging() reports

Hello there,

Thank you for testing it, I did some additional testing on my side and it seems to be isolated to digital pin 33 on the MEGA units that I have (Tried another MEGA as well).

The issue seems to be true regardless of what analog input I use so I'm chucking this up to a clone knockoff problem rather than a coding problem.

Thank you to those who helped look at this for me. My work around will be to jump the input on my custom PCB to another digital input pin on the MEGA. Thanks again and wishing you all well.

You did change to using INPUT_PULLUP for all button inputs?

Hello MarkT,

No as I am using pull down resistors. Correction on my previous post as well, the error does not seem to be isolated only to one pin which brings me back to something funky happening in the programming.

Anyone got any insights?

Can you write a minimal, complete and verifiable example (mcve) which demonstrates the problem.

Many times you will find the answer for your self when reducing your code to a minimal example and if not, it will make it a lot easier for people on this board to help find the root cause.

Hello Team,

I've broken down the code to the bare bones to hopefully get some insight on this.

Below you can see that when I don't measure the analog input, that my digitalRead inputs are reporting a LOW variable when the switch position is off:

When I turn the switch to the right position, then the digitalRead for the right indicator input responds correctly:

Similarly when I turn the switch to the left position, then the digitalRead for the left indicator input responds correctly:

Now, when I put the analogRead statement back into play and I upload it to the board, then I get a HIGH on the digital read input for the right indicator input without the switch being turned on:

The left indicator still responds as expected when I turn the switch on:

Now, when I remove my board from my circuit board, then the digitalRead for the right indicator input reads correctly again:

So this kind of leads me to a board problem, however, I've checked all my hardware to see whether I have any short circuits between my analog input and my digital input but there are none. I also rechecked (multiple times) that there are no short circuits between 5V and the digitalRead input pin and there is not.

When not measuring the analog input, then I measure 0 volt from the right indicator digital input to ground when it is not turned on and this is expected. But as soon as I declare the analogRead statement, then I measure the 5 V available on the 5V pin on the right indicator digital input.

At this point in time I don't know what is left from right lol. I've attached the schematic diagram I put together in case someone might be able to pick something up there.

Vechile Controller - Board 1.pdf (108.8 KB)

Looking forward to potential feedback.

Code:


//  Speed Control Variables
//  ************************
#define Throttle_AI_Pin A2
unsigned int Throttle_Pedal_Input = 0;

//  Indicator Lights Varialbes
//  **************************

#define Left_Indicator_Lights_DI_Pin 32
#define Right_Indicator_Lights_DI_Pin 11
#define Left_Indicator_Lights_DO_Pin 35
#define Right_Indicator_Lights_DO_Pin 34

int Left_Indicator_Lights_State = LOW;
int Left_Indicator_Input_State = LOW;
int Right_Indicator_Lights_State = LOW;
int Right_Indicator_Input_State = LOW;

unsigned long Previous_Millis = 0;        // will store last time LED was updated
unsigned long Current_Millis;
const long Timer_Interval = 400;           // interval at which to blink (milliseconds)

byte Left_Indicator;
byte Right_Indicator;

// Debugging Variables
// *******************

int Second_Check_Time = 1000;
long Prev_Second_Check_Time;

//  *************************************************

void setup()
{
  Serial.begin(250000);
  
  pinMode(Left_Indicator_Lights_DI_Pin, INPUT);
  pinMode(Right_Indicator_Lights_DI_Pin, INPUT);
  pinMode(Left_Indicator_Lights_DO_Pin, OUTPUT);  
  pinMode(Right_Indicator_Lights_DO_Pin, OUTPUT);

  pinMode(Throttle_AI_Pin, INPUT); 
}

void loop()
{


  Left_Indicator_Input_State = digitalRead(Left_Indicator_Lights_DI_Pin);
  Right_Indicator_Input_State = digitalRead(Right_Indicator_Lights_DI_Pin);

  Throttle_Pedal_Input = analogRead(Throttle_AI_Pin);
  
  Indicator_Function();

  Debugging();

}



/**************************************************************************************************************************************************************************
**************************************************                     Indicator Flicker Code                           ***************************************************
**************************************************************************************************************************************************************************/

void Indicator_Function()
{

  // Left Indicator function section
  // ********************************
    
  if(Left_Indicator_Input_State ==  HIGH)
  {
    digitalWrite(Left_Indicator_Lights_DO_Pin, HIGH);
  }

  else
  {
    Left_Indicator = 0;
    digitalWrite(Left_Indicator_Lights_DO_Pin, LOW);   
  }
  
  // Right Indicator function section
  // ********************************
    
  if(Right_Indicator_Input_State ==  HIGH)
  {
    digitalWrite(Right_Indicator_Lights_DO_Pin, HIGH);
  }

  else
  {
    digitalWrite(Right_Indicator_Lights_DO_Pin, LOW);
  }  
}

/**************************************************************************************************************************************************************************
**************************************************                            Debugging                                 ***************************************************
**************************************************************************************************************************************************************************/

void Debugging()
{
   //***********************************************************************

  if(millis() - Second_Check_Time > Prev_Second_Check_Time)
  {     
    Serial.print("Throttle Pedal Input:");
    Serial.print("\t\t");
    Serial.print(Throttle_Pedal_Input);
    Serial.print('\n'); 
    
    Serial.print("Left Indicator Input State:");
    Serial.print("\t");
    Serial.print(Left_Indicator_Input_State);
    Serial.print('\n');  
    
    Serial.print("Right Indicator Input State:");
    Serial.print("\t");
    Serial.print(Right_Indicator_Input_State);
    Serial.print('\n'); 
    
    //***********************************************************************
    
    Serial.print('\n'); 
    Serial.print('\n'); 
    
    Prev_Second_Check_Time = millis();
  }

  //***********************************************************************

}




//*************************************************************************************************************************************************************************

Code Attachment:

02_Throttle_Control_Bare_Bones.ino (4.2 KB)

**************************************************                     Indicator Flicker Code                           ***************************************************


void Indicator_Function()
{

  // Left Indicator function section
  // ********************************
    
  if(Left_Indicator_Input_State ==  HIGH)
  {
    digitalWrite(Left_Indicator_Lights_DO_Pin, HIGH);
  }

  else
  {
    Left_Indicator = 0;
    digitalWrite(Left_Indicator_Lights_DO_Pin, LOW);   
  }
  
  // Right Indicator function section
  // ********************************
    
  if(Right_Indicator_Input_State ==  HIGH)
  {
    digitalWrite(Right_Indicator_Lights_DO_Pin, HIGH);
  }

  else
  {
    digitalWrite(Right_Indicator_Lights_DO_Pin, LOW);
  }  
}

I think you're NOT setting Right_Indicator to 0 in your else function??
ie : Right_Indicator = 0;
as you do in your Left_indicator function

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.