Bike indicator system, advice needed.

Hey, I have designed a circuit on tinkercad for some bike indicators.
The problem I am having is that I am unable to make it so that you can press the other function buttons while another function is being carried out e.g. while the indicator sequence is being performed the brake light cannot be pressed until the indicator has completed the sequence. Any help would be much appreciated.

I have tried to implement multiple loops but I have hit a brick wall :frowning:

Thanks :slight_smile:

const int leftbutton = 4;
const int rightbutton = 2;
const int stopbutton = 3;
const int leftled = 10;
const int rightled = 9;
const int stopled = 13;
const int leftledtwo = 11;
const int leftledthree= 12;
const int rightledtwo = 8;
const int rightledthree= 7;
const int buzzer = 6;
const int buzzerbutton = 5;
int leftbuttonstate = 0;
int rightbuttonstate = 0;
int stopbuttonstate = 0;
int buzzerbuttonstate = 0;

void setup() {
  pinMode (leftbutton, INPUT);
  pinMode (rightbutton, INPUT);
  pinMode (stopbutton, INPUT);
  pinMode (buzzerbutton, INPUT);
  pinMode (leftled, OUTPUT);
  pinMode (rightled, OUTPUT);
  pinMode (stopled, OUTPUT);
  pinMode (leftledtwo, OUTPUT);
  pinMode (leftledthree, OUTPUT);
  pinMode (rightledtwo, OUTPUT);
  pinMode (rightledthree, OUTPUT);
  pinMode (buzzer, OUTPUT);
  Serial.begin(9600);
} 
           
void loop(){
 leftbuttonstate = digitalRead (leftbutton);
 rightbuttonstate = digitalRead (rightbutton);
 stopbuttonstate = digitalRead (stopbutton);
 buzzerbuttonstate = digitalRead (buzzerbutton);
  
  Serial.println(stopbuttonstate);
  Serial.println(leftbuttonstate);
  Serial.println(rightbuttonstate);
  Serial.println(buzzerbutton);
  
  if(leftbuttonstate == HIGH){
    digitalWrite (leftled, HIGH);
    digitalWrite (leftledtwo, LOW);
    digitalWrite (leftledthree, LOW);
     delay(1000);
    
    digitalWrite (leftled, LOW);
    digitalWrite (leftledtwo, HIGH);
    digitalWrite (leftledthree, LOW);
    delay(1000);
    
    digitalWrite (leftled, LOW);
    digitalWrite (leftledtwo, LOW);
    digitalWrite (leftledthree, HIGH);
    delay(1000);
    
    digitalWrite (leftled, HIGH);
    digitalWrite (leftledtwo, LOW);
    digitalWrite (leftledthree, LOW);
    delay(1000);
    
      digitalWrite (leftled, LOW);
    digitalWrite (leftledtwo, HIGH);
    digitalWrite (leftledthree, LOW);
    delay(1000);
      
    digitalWrite (leftled, LOW);
    digitalWrite (leftledtwo, LOW);
    digitalWrite (leftledthree, HIGH);
    delay(1000);
      
    digitalWrite (leftled, LOW);
    digitalWrite (leftledtwo, LOW);
    digitalWrite (leftledthree, LOW);
    delay(1000);
  }
  else if (rightbuttonstate == HIGH){
    digitalWrite (rightled, HIGH);
    digitalWrite (rightledtwo, LOW);
    digitalWrite (rightledthree, LOW);
    delay(1000);
    
    digitalWrite (rightled, LOW);
    digitalWrite (rightledtwo, HIGH);
    digitalWrite (rightledthree, LOW);
    delay(1000);
    
    digitalWrite (rightled, LOW);
    digitalWrite (rightledtwo, LOW);
    digitalWrite (rightledthree, HIGH);
    delay(1000);
    
    digitalWrite (rightled, HIGH);
    digitalWrite (rightledtwo, LOW);
    digitalWrite (rightledthree, LOW);
    delay(1000);
    
    digitalWrite (rightled, LOW);
    digitalWrite (rightledtwo, HIGH);
    digitalWrite (rightledthree, LOW);
    delay(1000);
    
    digitalWrite (rightled, LOW);
    digitalWrite (rightledtwo, LOW);
    digitalWrite (rightledthree, HIGH);
    delay(1000);
    
    digitalWrite (rightled, LOW);
    digitalWrite (rightledtwo, LOW);
    digitalWrite (rightledthree, LOW);
    delay(1000);
  }
  
if(stopbuttonstate == HIGH){
    digitalWrite (stopled, HIGH);
    delay(100);
    digitalWrite (stopled, LOW);
}
  
if(buzzerbuttonstate == HIGH){
    digitalWrite (buzzer, HIGH);
    delay(100);
    digitalWrite (buzzer, LOW);  
  }
}

Look at:

IDE: File --> Examples --> 02.Digital --> BlinkWithoutDelay
Using millis() for timing. A beginners guide
Demonstration code for several things at the same time
State Machines

As long as you use the delay(...) function you are likely to have the problem "...I am unable to make it so that you can press the other function buttons while another function is being carried out...".

Use millis() instead, but you will have to structure your program differently.

The examples listed by gfvalvo are a great place to start.

delay(...) should come with a big warning along the lines of "The delay(...) function is likely to get you into a lot of trouble. Unless you are an expert, use it only for demonstrations, toy programs, and debugging."

Thank you very much guys. Much appreciated.