Panel Route Lights

Hello all,

Usual start- only just got started with programming having had a good 12 year gap since using Arduino at University! very rusty indeed.

What I'm looking to do is have 2 buttons and an LED. The 1st button, when pressed once will set a while loop that gets the LED blinking for a set amount of times, and the 2nd button should break the 1st loop and set the LED steady.

Following on from that I'll have the whole lot reset, but I haven't written that part yet as I cannot get the code to respond how I'd like. I've got to the stage where I've poured over it so much I've somewhat lost my way!

The code is a little clunky at the moment, something I hope to tidy up as experience goes on but ultimately I would like to get the code working first!

Assistance and pointers gratefully received.

const int ledPIN =  7;
const int button1 = 2;
const int button2 = 4;

int buttonState = 0;

void setup() {
  
 pinMode (ledPIN, OUTPUT);
 pinMode (button1, INPUT_PULLUP);
 pinMode (button2, INPUT_PULLUP);
}

void loop() {

buttonState = digitalRead(button1);

while(buttonState == 0){                                 
  digitalWrite(ledPIN, HIGH);      
  delay(750);
  digitalWrite(ledPIN, LOW);
  delay(750);
  digitalWrite(ledPIN, HIGH);      
  delay(750);
  digitalWrite(ledPIN, LOW);
  delay(750); 
  digitalWrite(ledPIN, HIGH);      
  delay(750);
  digitalWrite(ledPIN, LOW);
  delay(750);
   digitalWrite(ledPIN, HIGH);      
  delay(750);
  digitalWrite(ledPIN, LOW);
  delay(750);     
  digitalWrite(ledPIN, HIGH);      
  delay(750);
  digitalWrite(ledPIN, LOW);
  delay(750);     
  digitalWrite(ledPIN, HIGH);      
  delay(750);
  digitalWrite(ledPIN, LOW);
  delay(750);                                  
  buttonState = 1;
}

buttonState = digitalRead(button1);
digitalWrite(ledPIN, LOW);
while((digitalRead(button2) == 1) && (digitalRead(button1) == 1));{
  digitalWrite(ledPIN, HIGH);
  
}
}

Did you intend to put the semicolon at the end of the last while loop?
Your braces suggest not.

TheMemberFormerlyKnownAsAWOL:
Did you intend to put the semicolon at the end of the last while loop?
Your braces suggest not.

I didn't, but once removed had little affect on the code regrettably!

tom92240:
the 2nd button should break the 1st loop and set the LED steady.

The second button is not checked the entire time the code is stepping through:

digitalWrite(ledPIN, LOW);
  delay(750);
// etc., etc.

Read up on: several things at the same time and using millis() for timing so you can get rid of delay().