2 buttons controlling the same 3 led

Hi ,

I am trying to achieve the following:

I have 2 buttons (2,3) that control 3 LED (4,5,6)

when i press 2 ==> 4,5,6 HIGH
When i press 3 ===> 4 to remain HIGH and 5,6 to BLINK
when i press both ==> 4,5,6 blinks

for some reason the priority of the LED and the override pattern is what is a bit confusing to me .

if someone could help with the code on this or guidance

thanks,

if someone could help with the code

As a start, please post your code using the guidance in read this before posting a programming question

You need to be clear when you say "when i press 2" whether you mean that you want to hold down the button or press it for a moment. How are the buttons wired ? Pullup or pulldown resistors in place ?

UKHeliBob:
As a start, please post your code using the guidance in read this before posting a programming question

You need to be clear when you say “when i press 2” whether you mean that you want to hold down the button or press it for a moment. How are the buttons wired ? Pullup or pulldown resistors in place ?

PULLUP wired – AND HOLD until i remove my finger of it.

const int brakesPin = 2; //pin number of brake wire input
const int brakesPin2 = 3;
int brakesState = 0;

long flashDelay = 250;
long flashDelay2 = 250; //time LED is on
long flashDelay3 = 250;

boolean LED10state = false;     // the LED will turn ON in the first iteration of loop()
boolean LED11state = false;     // need to seed the light to be OFF
boolean LED12state = false;
boolean LED5state = false;     // the LED will turn ON in the first iteration of loop()
boolean LED6state = false;     // need to seed the light to be OFF
boolean LED7state = false;

long waitUntil10 = 0;
long waitUntil11 = 250;         // the seed will determine time between LEDs
long waitUntil12 = 250;

int ledPins[] = { 12, 11, 10, 9, 8, 7, 6 };       // an array of pin numbers to which LEDs are attached
int pinCount = 7;  

void setup() {

	for (int thisPin = 0; thisPin < pinCount; thisPin++)  
	{
		pinMode(ledPins[thisPin], OUTPUT);      
	}
	pinMode(brakesPin, INPUT_PULLUP);
}

void loop() 
{

	int state = digitalRead(brakesPin);
	int state2 = digitalRead(brakesPin2);

	switch(state|state2)
	{
	case 0: // Chase

		all();		
		break;
	case 1: // Random
		digitalWrite(6, LOW);     // each iteration of loop() will set the IO pins,
		digitalWrite(7, LOW);
		digitalWrite(8, LOW);
		digitalWrite(10, LOW);     // each iteration of loop() will set the IO pins,
		digitalWrite(11, LOW);
		digitalWrite(12, LOW);
		digitalWrite(9, LOW);

		break;
	}
}


void brake()
{
	digitalWrite(10, LED10state);     // each iteration of loop() will set the IO pins,
	digitalWrite(11, LED11state);
	digitalWrite(12, LED12state);
	digitalWrite(6, LED5state);     // each iteration of loop() will set the IO pins,
	digitalWrite(7, LED6state);
	digitalWrite(8, LED7state);
	// checking to see if enough time has elapsed
	if (millis() >= waitUntil10) {
		LED10state = !(LED10state);
		waitUntil10 += flashDelay;
		LED7state = !(LED7state);
		waitUntil10 += flashDelay;
		// this if-statement will not execute for another 1000 milliseconds
	}
	// checking to see if enough time has elapsed
	if (millis() >= waitUntil11) {
		LED11state = !(LED11state);
		waitUntil11 += flashDelay2;
		LED6state = !(LED6state);
		waitUntil11 += flashDelay2;
		// this if-statement will not execute for another 1000 milliseconds
	}
	// keep in mind, waitUntil12 was already seeded with a value of 500
	if (millis() >= waitUntil12) {
		LED12state = !(LED12state);
		waitUntil12 += flashDelay3;
		LED5state = !(LED5state);
		waitUntil12 += flashDelay3;
	}

}

void all()
{
	digitalWrite(10, HIGH);     // each iteration of loop() will set the IO pins,
	digitalWrite(11, HIGH);
	digitalWrite(12, HIGH);
	digitalWrite(6, HIGH);     // each iteration of loop() will set the IO pins,
	digitalWrite(7, HIGH);
	digitalWrite(8, HIGH);
	digitalWrite(9, HIGH);

}

you don't set pinmode for brakesPin2 so that probably doesn't work

your use of millis in void brake is weird (might work after a few loops if flashDelay is added enough times to catch up and pass millis. would have to test that idea.

I don't see a function call from the loop using void brake()

looks complicated for a simple sketch

look at the example blink with out delay then add a few "if" and that should be enough code to do what you are asking. (depending on what you class as blinking, as in together, random, alternating, chasing)

I would handle the buttons this way

code is read top to bottom and left to right so last line wins

a=0
a=1
a=2
a=3

at this point A will always be 3

now if we add a few “if” we get

  state = 0;
  if (button1 == HIGH) {
    state = 1;
  }
  if (button2 == HIGH) {
    state = 2;
  }
  if (button1 == HIGH && button2 == HIGH) {
    state = 3;
  }

now we can use a “switch” to make the leds do what ever you want

we can also use a self resetting timer to handle the blinking

const int brakesPin = 2; //pin number of brake wire input
const int brakesPin2 = 3;
const int led1 = 4;
const int led2 = 5;
const int led3 = 6;
unsigned long previousMillis = 0;
byte chase = 0;
byte state = 0;
bool toggle = 0;

void setup() {

  pinMode(brakesPin, INPUT_PULLUP);
  pinMode(brakesPin2, INPUT_PULLUP);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}

void loop() {
  //I have 2 buttons (2,3) that control 3 LED (4,5,6)
  //when i press 2 ==> 4,5,6 HIGH
  //When i press 3 ===> 4 to remain HIGH and 5,6 to BLINK
  //when i press both ==> 4,5,6 blinks
  //PULLUP wired  -- AND HOLD until i remove my finger of  it.

  unsigned long currentMillis = millis();//used by timer loop
  int button1 = digitalRead(brakesPin);
  int button2 = digitalRead(brakesPin2);

  if (currentMillis - previousMillis >= 330) {//every 1/3 second do this
    toggle = !toggle;//used to flash leds
    chase++;//used to chase leds
    previousMillis = currentMillis;//reset time stamp for repeat
  }

  if (chase >= 3) {//chase 0-1-2-0-1-2-etc
    chase = 0;
  }

  state = 0;//set state at no button pushed
  if (button1 == HIGH) {//see if button pressed
    state = 1;
  }
  if (button2 == HIGH) {//see if button pressed
    state = 2;
  }
  if (button1 == HIGH && button2 == HIGH) {//see if both buttons pushed
    state = 3;
  }
  //last line wins on state

  switch (state) {
    case 0://no button pushed
      digitalWrite (led1, LOW);//all off
      digitalWrite (led2, LOW);
      digitalWrite (led3, LOW);
      break;
    case 1://button one pushed
      digitalWrite (led1, HIGH);//all on
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      break;
    case 2://button two pushed
      digitalWrite (led1, HIGH);//led1 on
      if (toggle == 1) {
        digitalWrite (led2, HIGH);//toggle flash leds 2 and 3
        digitalWrite (led3, LOW);
      } else {
        digitalWrite (led2, LOW);
        digitalWrite (led3, HIGH);
      }
      break;
    case 3://both buttons pushed

      switch (chase) {
        case 0:
          digitalWrite (led1, HIGH);//one led on at a time chase
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          break;
        case 1:
          digitalWrite (led1, LOW);
          digitalWrite (led2, HIGH);
          digitalWrite (led3, LOW);
          break;
        case 2:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, HIGH);
          break;
      }//end of chase switch

      break;
  }//end of state switch

}//end of loop

this code was not tested as it was to written to show a idea. (mostly cut and paste so there may be mistakes)

You started off on the right foot with ledPins, then you squandered it by only using it in setup for pin initialization (when for loops could be used in many places for pin output). Instead of creating a parallel array for state, you create a whole bunch of named variables for each pin. What a waste! It also created a mess.

gpop1:
I would handle the buttons this way

code is read top to bottom and left to right so last line wins

a=0
a=1
a=2
a=3

at this point A will always be 3

now if we add a few "if" we get

  state = 0;

if (button1 == HIGH) {
    state = 1;
  }
  if (button2 == HIGH) {
    state = 2;
  }
  if (button1 == HIGH && button2 == HIGH) {
    state = 3;
  }





now we can use a "switch" to make the leds do what ever you want

we can also use a self resetting timer to handle the blinking




const int brakesPin = 2; //pin number of brake wire input
const int brakesPin2 = 3;
const int led1 = 4;
const int led2 = 5;
const int led3 = 6;
unsigned long previousMillis = 0;
byte chase = 0;
byte state = 0;
bool toggle = 0;

void setup() {

pinMode(brakesPin, INPUT_PULLUP);
  pinMode(brakesPin2, INPUT_PULLUP);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}

void loop() {
  //I have 2 buttons (2,3) that control 3 LED (4,5,6)
  //when i press 2 ==> 4,5,6 HIGH
  //When i press 3 ===> 4 to remain HIGH and 5,6 to BLINK
  //when i press both ==> 4,5,6 blinks
  //PULLUP wired  -- AND HOLD until i remove my finger of  it.

unsigned long currentMillis = millis();//used by timer loop
  int button1 = digitalRead(brakesPin);
  int button2 = digitalRead(brakesPin2);

if (currentMillis - previousMillis >= 330) {//every 1/3 second do this
    toggle = !toggle;//used to flash leds
    chase++;//used to chase leds
    previousMillis = currentMillis;//reset time stamp for repeat
  }

if (chase >= 3) {//chase 0-1-2-0-1-2-etc
    chase = 0;
  }

state = 0;//set state at no button pushed
  if (button1 == HIGH) {//see if button pressed
    state = 1;
  }
  if (button2 == HIGH) {//see if button pressed
    state = 2;
  }
  if (button1 == HIGH && button2 == HIGH) {//see if both buttons pushed
    state = 3;
  }
  //last line wins on state

switch (state) {
    case 0://no button pushed
      digitalWrite (led1, LOW);//all off
      digitalWrite (led2, LOW);
      digitalWrite (led3, LOW);
      break;
    case 1://button one pushed
      digitalWrite (led1, HIGH);//all on
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      break;
    case 2://button two pushed
      digitalWrite (led1, HIGH);//led1 on
      if (toggle == 1) {
        digitalWrite (led2, HIGH);//toggle flash leds 2 and 3
        digitalWrite (led3, LOW);
      } else {
        digitalWrite (led2, LOW);
        digitalWrite (led3, HIGH);
      }
      break;
    case 3://both buttons pushed

switch (chase) {
        case 0:
          digitalWrite (led1, HIGH);//one led on at a time chase
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          break;
        case 1:
          digitalWrite (led1, LOW);
          digitalWrite (led2, HIGH);
          digitalWrite (led3, LOW);
          break;
        case 2:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, HIGH);
          break;
      }//end of chase switch

break;
  }//end of state switch

}//end of loop




this code was not tested as it was to written to show a idea. (mostly cut and paste so there may be mistakes)

Thank you so much gpopl , gives me a lot to work with, appreciate it!

with this , how can i get the chase to start always from a specific led , seems random on button push

const int b1 = 2; //pin number of brake wire input
const int b2 = 3;
const int b3 = 4;

const int led1 = 6;
const int led2 = 7;
const int led3 = 8;
const int led4 = 9;
const int led5 = 10;
const int led6 = 11;
const int led7 = 12;

unsigned long previousMillis = 0;
byte chase = 0;
byte state = 0;
bool toggle = 0;

void setup()
{
  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
  pinMode(b3, INPUT_PULLUP);
  pinMode(led1, OUTPUT);  // 7 led in total
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);

}

void loop()
{
  //I have 2 buttons (2,3) that control 3 LED (4,5,6)
  //when i press 2 ==> 4,5,6 HIGH
  //When i press 3 ===> 4 to remain HIGH and 5,6 to BLINK
  //when i press both ==> 4,5,6 blinks
  //PULLUP wired  -- AND HOLD until i remove my finger of  it.

  unsigned long currentMillis = millis();//used by timer loop
  int button1 = digitalRead(b1);
  int button2 = digitalRead(b2);
  int button3 = digitalRead(b3);

  if (currentMillis - previousMillis >= 330)//every 1/3 second do this
  {
    toggle = !toggle;                  //used to flash leds
    chase++;                           //used to chase leds
    previousMillis = currentMillis;    //reset time stamp for repeat
  }

  if (chase >= 8)//chase 0-1-2-0-1-2-etc
  {
    chase = 0;
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  state = 0;                                   //set state at no button pushed
  if (button1 == LOW)
  { //see if button pressed
    state = 1;
  }
  if (button2 == LOW)
  { //see if button pressed
    state = 2;
  }
  if (button3 == LOW)
  { //see if both buttons pushed
    state = 3;
  }
  if (button1 == LOW && button2 == LOW )
  { //see if both buttons pushed
    state = 4;
  }
  if (button1 == LOW && button3 == LOW)
  { //see if both buttons pushed
    state = 5;
  }
  //last line wins on state
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  switch (state)
  {
    case 0://no button pushed
      digitalWrite (led1, LOW);//all off
      digitalWrite (led2, LOW);
      digitalWrite (led3, LOW);
      digitalWrite (led4, LOW);
      digitalWrite (led5, LOW);
      digitalWrite (led6, LOW);
      digitalWrite (led7, LOW);
      break;

    case 1://button one pushed
      digitalWrite (led1, HIGH);//all on
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      digitalWrite (led4, HIGH);
      digitalWrite (led5, HIGH);
      digitalWrite (led6, HIGH);
      digitalWrite (led7, HIGH);
      break;

    case 2://button two pushed
      digitalWrite (led1, HIGH);//led1 on
      if (toggle == 1)
      {
        digitalWrite (led2, HIGH);//toggle flash leds 2 and 3
        digitalWrite (led3, LOW);
      } else
      {
        digitalWrite (led2, LOW);
        digitalWrite (led3, HIGH);
      }
      break;

    case 3://both buttons pushed
      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      switch (chase)
      {
        case 0:
          digitalWrite (led1, HIGH);//one led on at a time chase
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 1:
          digitalWrite (led1, LOW);
          digitalWrite (led2, HIGH);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 2:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, HIGH);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 3:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, HIGH);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 4:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, HIGH);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 5:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, HIGH);
          digitalWrite (led7, LOW);
          break;
        case 6:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, HIGH);
          break;
      }//end of chase switch
      break;
  }//end of state switch
}//end of loop

destiny2008:
with this , how can i get the chase to start always from a specific led , seems random on button push

const int b1 = 2; //pin number of brake wire input

const int b2 = 3;
const int b3 = 4;

const int led1 = 6;
const int led2 = 7;
const int led3 = 8;
const int led4 = 9;
const int led5 = 10;
const int led6 = 11;
const int led7 = 12;

unsigned long previousMillis = 0;
byte chase = 0;
byte state = 0;
bool toggle = 0;

void setup()
{
  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
  pinMode(b3, INPUT_PULLUP);
  pinMode(led1, OUTPUT);  // 7 led in total
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);

}

void loop()
{
  //I have 2 buttons (2,3) that control 3 LED (4,5,6)
  //when i press 2 ==> 4,5,6 HIGH
  //When i press 3 ===> 4 to remain HIGH and 5,6 to BLINK
  //when i press both ==> 4,5,6 blinks
  //PULLUP wired  – AND HOLD until i remove my finger of  it.

unsigned long currentMillis = millis();//used by timer loop
  int button1 = digitalRead(b1);
  int button2 = digitalRead(b2);
  int button3 = digitalRead(b3);

if (currentMillis - previousMillis >= 330)//every 1/3 second do this
  {
    toggle = !toggle;                  //used to flash leds
    chase++;                          //used to chase leds
    previousMillis = currentMillis;    //reset time stamp for repeat
  }

if (chase >= 8)//chase 0-1-2-0-1-2-etc
  {
    chase = 0;
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  state = 0;                                  //set state at no button pushed
  if (button1 == LOW)
  { //see if button pressed
    state = 1;
  }
  if (button2 == LOW)
  { //see if button pressed
    state = 2;
  }
  if (button3 == LOW)
  { //see if both buttons pushed
    state = 3;
  }
  if (button1 == LOW && button2 == LOW )
  { //see if both buttons pushed
    state = 4;
  }
  if (button1 == LOW && button3 == LOW)
  { //see if both buttons pushed
    state = 5;
  }
  //last line wins on state
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  switch (state)
  {
    case 0://no button pushed
      digitalWrite (led1, LOW);//all off
      digitalWrite (led2, LOW);
      digitalWrite (led3, LOW);
      digitalWrite (led4, LOW);
      digitalWrite (led5, LOW);
      digitalWrite (led6, LOW);
      digitalWrite (led7, LOW);
      break;

case 1://button one pushed
      digitalWrite (led1, HIGH);//all on
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      digitalWrite (led4, HIGH);
      digitalWrite (led5, HIGH);
      digitalWrite (led6, HIGH);
      digitalWrite (led7, HIGH);
      break;

case 2://button two pushed
      digitalWrite (led1, HIGH);//led1 on
      if (toggle == 1)
      {
        digitalWrite (led2, HIGH);//toggle flash leds 2 and 3
        digitalWrite (led3, LOW);
      } else
      {
        digitalWrite (led2, LOW);
        digitalWrite (led3, HIGH);
      }
      break;

case 3://both buttons pushed
      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      switch (chase)
      {
        case 0:
          digitalWrite (led1, HIGH);//one led on at a time chase
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 1:
          digitalWrite (led1, LOW);
          digitalWrite (led2, HIGH);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 2:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, HIGH);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 3:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, HIGH);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 4:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, HIGH);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 5:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, HIGH);
          digitalWrite (led7, LOW);
          break;
        case 6:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, HIGH);
          break;
      }//end of chase switch
      break;
  }//end of state switch
}//end of loop

you would have to set a flag so you enter the switch at the same point then once the flag is set run the code normal

something like

(case 3 before switch)

if (onetime==0){
chase=0;
onetime=1}

(placed in case 0 no button)

onetime=0;

Perfect! Thank you!

some point in the future you should think about recoding the chase using the array from your original sketch then just ++ the led

something like

state case 3 turn all off then just turn one one based on a counter. (you can do a function call as this is the same as the code required for state case 0)
With 3 leds the switch looks ok but when you get to 7 leds its a lot of code that's kinda repetitive.

not something that needs to be done now but just a different way to think about it in the future (as you learn more In the future you will revisit a lot of your original codes....lol)

 case 2://button two pushed
      //digitalWrite (led1, HIGH);//led1 on
      
      if (toggle == 1)
      {
        if ( currentMillis - previousMillis >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
        {
          previousMillis = currentMillis;  // remember the time now
          i = ++i % (numberOfBlades - 1);        // advance i handle rollover
          for (int n = 0; n < numberOfBlades; n++) // display with new i
          {
            if ( n == i ) digitalWrite(ledPin[n], HIGH);
            else digitalWrite(ledPin[n], LOW);
          }
        }
      }
      break;

getting it down to something like this , but working on the issue above to set a starting led instead of random again :slight_smile:

perhaps…?

 if (onetime == 0)
      {
        i = 0;
        onetime = 1;
      }

maybe but try to avoid using a for in this instance as that will make the leds chase with out reading the button.

just add a number then use a if to roll the number over

if (ledOn>=7) {
ledOn = 0;
}

timer advances ledOn

ledOn++;
if (ledOn>=7) {
ledOn = 0;
}

fuction call all led off

ledOff();
now digitalWrite the pin based on ledOn to high

p.s (watch previousMillis you don't want to use the same one twice)

this seems to work for now , i am sure it can be cleaned in a better way…

const int b1 = 2; //pin number of brake wire input
const int b2 = 3;
const int b3 = 4;

const int led1 = 6;
const int led2 = 7;
const int led3 = 8;
const int led4 = 9;
const int led5 = 10;
const int led6 = 11;
const int led7 = 12;

unsigned long previousMillis = 0;
unsigned long interval = 120;
byte chase = 0;
byte state = 0;
bool toggle = 0;
//////////////////////////////////////////////

const int numberOfBlades = 7;
int ledPin[numberOfBlades] = {6, 7, 8, 9, 10, 11, 12};
unsigned long interval2 = 100;
int i = 0;


int onetime;
//////////////////////////////////////////////
void setup()
{
  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
  pinMode(b3, INPUT_PULLUP);
  pinMode(led1, OUTPUT);  // 7 led in total
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);

  for (int i = 0; i < numberOfBlades; i++)
  {
    pinMode(ledPin[i], OUTPUT);
    digitalWrite(ledPin[i], LOW); // all LEDs off
  }
}

void loop()
{
  unsigned long currentMillis = millis();//used by timer loop
  int button1 = digitalRead(b1);
  int button2 = digitalRead(b2);
  int button3 = digitalRead(b3);

  if (currentMillis - previousMillis >= 120)//every 1/3 second do this
  {
    toggle = !toggle;                  //used to flash leds
    chase++;                           //used to chase leds
    previousMillis = currentMillis;    //reset time stamp for repeat
  }

  if (chase >= 8)//chase 0-1-2-0-1-2-etc
  {
    chase = 0;
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  state = 0;                                   //set state at no button pushed
  if (button1 == LOW)
  { //see if button pressed
    state = 1;
  }
  if (button2 == LOW)
  { //see if button pressed
    state = 2;
  }
  if (button3 == LOW)
  { //see if both buttons pushed
    state = 3;
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if (button1 == LOW && button2 == LOW )
  { //see if both buttons pushed
    state = 4;
  }
  if (button1 == LOW && button3 == LOW)
  { //see if both buttons pushed
    state = 5;
  }
  //last line wins on state
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  switch (state)
  {
    case 0://no button pushed
      onetime = 0;
      digitalWrite (led1, LOW);//all off
      digitalWrite (led2, LOW);
      digitalWrite (led3, LOW);
      digitalWrite (led4, LOW);
      digitalWrite (led5, LOW);
      digitalWrite (led6, LOW);
      digitalWrite (led7, LOW);
      break;

    case 1://button one pushed
      digitalWrite (led1, HIGH);//all on
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      digitalWrite (led4, HIGH);
      digitalWrite (led5, HIGH);
      digitalWrite (led6, HIGH);
      digitalWrite (led7, HIGH);
      break;

    case 2://button two pushed
      //digitalWrite (led1, HIGH);//led1 on
      if (onetime == 0)
      {
        i = -1;
        onetime = 1;
      }

      if ( currentMillis - previousMillis >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
      {
        previousMillis = currentMillis;  // remember the time now
        i = ++i % (numberOfBlades);        // advance i handle rollover
        for (int n = 0; n < numberOfBlades; n++) // display with new i
        {
          if ( n == i )
            digitalWrite(ledPin[n], HIGH);
          else
            digitalWrite(ledPin[n], LOW);
        }
      }

      break;

    case 3://button three pushed
      if (onetime == 0)
      {
        chase = 0;
        onetime = 1;
      }
      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      switch (chase)
      {
        case 0:
          digitalWrite (led1, HIGH);//one led on at a time chase
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 1:
          digitalWrite (led1, LOW);
          digitalWrite (led2, HIGH);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 2:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, HIGH);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 3:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, HIGH);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 4:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, HIGH);
          digitalWrite (led6, LOW);
          digitalWrite (led7, LOW);
          break;
        case 5:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, HIGH);
          digitalWrite (led7, LOW);
          break;
        case 6:
          digitalWrite (led1, LOW);
          digitalWrite (led2, LOW);
          digitalWrite (led3, LOW);
          digitalWrite (led4, LOW);
          digitalWrite (led5, LOW);
          digitalWrite (led6, LOW);
          digitalWrite (led7, HIGH);
          break;
      }//end of chase switch
      break;

    case 4://2 buttons pushed
      digitalWrite (led1, HIGH);
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      digitalWrite (led4, HIGH);
      if (onetime == 0)
      {
        i = -1;
        onetime = 1;
      }

      if ( currentMillis - previousMillis >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
      {
        previousMillis = currentMillis;  // remember the time now
        i = ++i % (numberOfBlades);        // advance i handle rollover
        for (int n = 0; n < numberOfBlades; n++) // display with new i
        {
          if ( n == i )
            digitalWrite(ledPin[n], HIGH);
          else
            digitalWrite(ledPin[n], LOW);
        }
      }

      break;
  }//end of state switch
}//end of loop

you can not use the same previousMillis in different timers

this

  if ( currentMillis - previousMillis >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
      {
        previousMillis = currentMillis;

should be

  if ( currentMillis - previousMillis2 >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
      {
        previousMillis2 = currentMillis;

kinda lost the plan with the extra buttons and what you are doing with the leds which isn’t a problem I just haven’t looked at the section other than the timers

post code has notes it has not been tested

const int b1 = 2; //pin number of brake wire input
const int b2 = 3;
const int b3 = 4;

const int led1 = 6;
const int led2 = 7;
const int led3 = 8;
const int led4 = 9;
const int led5 = 10;
const int led6 = 11;
const int led7 = 12;
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long interval1 = 110;
unsigned long interval2 = 100;
unsigned long interval3 = 100;
byte ledOn = 0;
byte state = 0;
bool toggle = 0;
byte prevLedOn = 0;
//////////////////////////////////////////////

const int numberOfBlades = 7;
int ledPin[numberOfBlades] = {6, 7, 8, 9, 10, 11, 12};

int i = 0;


int onetime;
//////////////////////////////////////////////
void setup()
{
  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
  pinMode(b3, INPUT_PULLUP);

  //using for to set pinmode would be valid here

  pinMode(led1, OUTPUT);  // 7 led in total
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  ledOff();//all leds off (no idea why as they should start that way)
}

void loop()
{
  unsigned long currentMillis = millis();//used by all timing loops
  int button1 = digitalRead(b1);
  int button2 = digitalRead(b2);
  int button3 = digitalRead(b3);

  if (currentMillis - previousMillis1 >= interval1)//every 1/3 second do this
  {
    toggle = !toggle;                  //used to flash leds
    ledOn++;                           //used to chase leds
    previousMillis1 = currentMillis;    //reset time stamp for repeat
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  state = 0;                                   //set state at no button pushed
  if (button1 == LOW)
  { //see if button pressed
    state = 1;
  }
  if (button2 == LOW)
  { //see if button pressed
    state = 2;
  }
  if (button3 == LOW)
  { //see if both buttons pushed
    state = 3;
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if (button1 == LOW && button2 == LOW )
  { //see if both buttons pushed
    state = 4;
  }
  if (button1 == LOW && button3 == LOW)
  { //see if both buttons pushed
    state = 5;
  }
  //last line wins on state
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  switch (state)
  {
    case 0://no button pushed
      onetime = 0;
      ledOff();//all leds off
      break;

    case 1://button one pushed
      digitalWrite (led1, HIGH);//all on
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      digitalWrite (led4, HIGH);
      digitalWrite (led5, HIGH);
      digitalWrite (led6, HIGH);
      digitalWrite (led7, HIGH);
      break;

    case 2://button two pushed
      //digitalWrite (led1, HIGH);//led1 on
      if (onetime == 0)//this line is in the wrong order which is why -1 works
      {
        i = -1;
        onetime = 1;
      }
      // this code looks like code in case 4 except interval?
      //if so move to funtion and pass interval or set interval and use as a global
      //using global just use on timer say interval2 and previousMillis2
      //then add interval2=110; or what ever in the switch before function call

      if ( currentMillis - previousMillis2 >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
      {
        previousMillis2 = currentMillis;  // remember the time now
        i = ++i % (numberOfBlades);        // advance i handle rollover
        for (int n = 0; n < numberOfBlades; n++) // display with new i
        {
          if ( n == i )
            digitalWrite(ledPin[n], HIGH);
          else
            digitalWrite(ledPin[n], LOW);
        }
      }

      break;

    case 3://button three pushed
      if (onetime == 0)
      {
        ledOn = 0;//force first led as starting point
        prevLedOn = 7; //force first digitalWrite
        onetime = 1;
      }
      if (ledOn >= 7) {
        ledOn = 0;//handle roll over of leds
      }
      if (ledOn != prevLedOn) {//if ledOn count changes
        ledOff();//all leds off
        digitalWrite(ledPin[ledOn], HIGH);//this led on
        prevLedOn = ledOn;//reset so change can be detected
      }
      break;

    case 4://2 buttons pushed
      digitalWrite (led1, HIGH);
      digitalWrite (led2, HIGH);
      digitalWrite (led3, HIGH);
      digitalWrite (led4, HIGH);
      if (onetime == 0)//this line is in the wrong order which is why -1 works
      {
        i = -1;
        onetime = 1;
      }

      if ( currentMillis - previousMillis3 >= interval3) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
      {
        previousMillis3 = currentMillis;  // remember the time now
        i = ++i % (numberOfBlades);        // advance i handle rollover
        for (int n = 0; n < numberOfBlades; n++) // display with new i
        {
          if ( n == i )
            digitalWrite(ledPin[n], HIGH);
          else
            digitalWrite(ledPin[n], LOW);
        }
      }

      break;
  }//end of state switch
}//end of loop

void ledOff() {

  digitalWrite (led1, LOW);//all off
  digitalWrite (led2, LOW);
  digitalWrite (led3, LOW);
  digitalWrite (led4, LOW);
  digitalWrite (led5, LOW);
  digitalWrite (led6, LOW);
  digitalWrite (led7, LOW);
}

anytime you start to see the same code consider moving the code to a function

ok I see what you are doing in the for loops now and it makes sense

never use i unless you really have to as it looks like 1.

Even worse, never use l as it looks even more like 1

trying to get this to go opposite way right to left , any idea?

unsigned long currentMillis = millis();
  if (onetime == 0)
  {
    i = -1;
    onetime = 1;
  }

  if ( currentMillis - previousMillis >= interval2) // Arduino run time - changeTime value greater then ledDelay variable? Yes then
  {
    previousMillis = currentMillis;  // remember the time now
    i = ++i % (numberOfleds);        // advance i handle rollover
    for (int n = 0; n < numberOfleds; n++) // display with new i
    {
      if ( n == i )
        digitalWrite(ledPin[n], HIGH);
      else
        digitalWrite(ledPin[n], LOW);
    }
  }