Hi, I want to make a small circuit for my Bike Indicator. (1st button connect with Nano pin D11). (2nd button connect with Nano pin D12)
Here I install two buttons. One for Left indicator(connected with pin D9 of nano) to be flashed and other for led flashing (connected with pin D8 of nano) pattern change. But whenever I press the button for left indicator, the function occure after the led flashing patter fully completed. I need to run the left indicator to run instantly whenever i press the 1st button.
The Code is below:

/Name:chandrasekhar
developed for putting this pcb to bike for indicator flashing
contact t_tuku@yahoo.com/
#define leftLedOn PORTB |= (1 << PB0)
#define leftLedOff PORTB &= ~(1 << PB0)
#define rightLedOn PORTB |= (1 << PB1)
#define rightLedOff PORTB &= ~(1 << PB1)
bool Flag = 0;
bool Flag1 = 0;
/FUNCTION PROTOTYPE/
void Breath(); void Hazard(); void Flasher1(); void Flasher2(); void LeftLedFlash();
void RightLedFlash(); void PoliceStrobe(); void LeftIndicator(); void RightIndicator();
/FUNCTION PROTOTYPE END/
volatile int counter = 0;
void setup() {
cli();
PCICR |= (1 << PCIE0);
PCMSK0 |= (1 << PCINT3) | (1 << PCINT4);
DDRB |= (1 << PB0) | (1 << PB1) ; //LEDs ARE CONNECTED TO PB0 AND PB1, GND IS COMMON
DDRB &= ~(1 << PB3) | ~(1 << PB4);//INPUT BUTTON ON PB3 AND PB4
PORTB |= (1 << PB3) | (1 << PB4); //ACTIVATE INPUT_PULLUP
sei();
}
void loop() {
if (counter == 1) {
RightLedFlash();
}
if (counter == 2) {
LeftLedFlash();
}
if (counter == 3) {
Flasher1();
}
if (counter == 4) {
Flasher2();
}
if (counter == 5) {
PoliceStrobe();
}
if (counter == 6) {
LeftIndicator();
}
}
ISR(PCINT0_vect)
{
if ((PINB & (1 << PB3)) && Flag == 0)
{
delay(25);
counter++;
if (counter > 5)counter = 1;
}
if ((PINB & (1 << PB4)) && Flag1 == 0)
{
counter = 6;
}
}
void Hazard() {
leftLedOn;
rightLedOn;
delay(500);
leftLedOff;
rightLedOff;
delay(500);
}
void Flasher1() {
LeftLedFlash();
LeftLedFlash();
LeftLedFlash();
LeftLedFlash();
delay(200);
RightLedFlash();
RightLedFlash();
RightLedFlash();
RightLedFlash();
delay(200);
}
void Flasher2() {
rightLedOn;
delay(50);
rightLedOff;
leftLedOn;
delay(50);
leftLedOff;
delay(300);
leftLedOn;
delay(50);
leftLedOff;
rightLedOn;
delay(50);
rightLedOff;
delay(300);
}
void LeftLedFlash() {
leftLedOn;
delay(50);
leftLedOff;
delay(50);
}
void RightLedFlash() {
rightLedOn;
delay(50);
rightLedOff;
delay(50);
}
void PoliceStrobe() {
for (int i = 0; i < 3; i++) {
LeftLedFlash();
}
for (int i = 0; i < 3; i++) {
RightLedFlash();
}
}
void LeftIndicator() {
leftLedOn;
delay(500);
leftLedOff;
delay(500);
}
void RightIndicator() {
rightLedOn;
delay(500);
rightLedOff;
delay(500);
}