please help me. LED turning off after time period

hey people of the internet.

my names emmy and i am not very talented at this Arduino thing (i have to do it for Uni).

You all will probably think that i'm like an idiot but yo girl is really struggling.

so heres the sitch...

Im working on having 4 LEDs turn on consecutively with a push button which i have managed #woo!

but now i need each of the buttons to turn off after 5 seconds

i've been reading and watching a lot about the millis function but i'm really struggling to figure out how to actually use it within my code. i have a bad feeling that my codes gonna be like "computer says no and all"

thanks a bunch for any sort of help i do struggle to understand some of the code jargon but will try my best!

heres my code feel free to fix it up and code straight into it

please dont judge me, i think what ya'll do is super impressive and hard

thanks sorry for the essay xx

#define button 3
#define redLED 5
#define greenLED 6
#define yellowLED 7
#define blueLED 8

int state = 0;
int old = 0;
int buttonPoll = 0;

void setup() {
pinMode(button,INPUT);
pinMode(redLED,INPUT);
pinMode(greenLED,INPUT);
pinMode(yellowLED,INPUT);
pinMode(blueLED,INPUT);

digitalWrite(redLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, LOW);

}

void loop() {

buttonPoll = digitalRead(button);
if(buttonPoll == 1) {
delay (50);
buttonPoll = digitalRead(button);
if(buttonPoll == 0){
state = old +1 ;

}}

else{
delay(100);

}
switch (state){
case 1:
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, LOW);
old = state;

break;
case 2:
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, LOW);

old = state;
break;
case 3 :
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, HIGH);
digitalWrite(yellowLED, HIGH);
digitalWrite(blueLED, LOW);
old = state;
break;

case 4 :
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, HIGH);
digitalWrite(yellowLED, HIGH);
digitalWrite(blueLED, HIGH);
old = state;
break;

default:
digitalWrite(redLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, LOW );

old = 0;
break;

}
}

Hi emmyharkins, welcome.

First of all, you put this question in the wrong section.
It's a good idea to read any instructions (click !) before you start on something new.

You're asking to switch each of the buttons off after 5 seconds.
But there is only one single button.

So i assume you meant to ask to switch off a LED 5 seconds after it was lit.
To do that, you need to keep track of time.
But you're not doing that with this code.
There are some delay()s in there, but those are not your friend here.

You mentioned you did study millis, but there's no attempt to use that in your present code.
You are trying to remember past and present state of something, which is only part of the time related solution you're looking for.

Asking people to do your work for you, isn't going to get you trhough your education.
So i'll try to help you but i won't do the work for you.
You have to figure things out yourself.
If you see problems, break them down into smaller sub-problems.
And repeat until each of these sub-problem is easy to answer.

If you have some new questions on a revised code, show the revised code (in the way described in the instructions mentioned above) along with your question.

Lots of success.

The demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

…R