led and buttons

Hi everyone, i need help. I have a project about motorized roation stage but for now i am dealing with simple Arduino. I have an assigment that i have to submit by monday. I have to press a certain amount of time(ex 5 times) and the led has to light up the same amount of time(5 times) with a delay. I know it a simple code but i just started learning so i am not too good at it. The teacher also want the amount of time to be displayed in a dialog box.
THanks, and sorry for the grammatical mistakes, my english is not too good.

What code and circuit do you have so far? Have you worked through the examples?

You'll find members here will bend over backwards to help you, but you have to provide your work so far, and say what you've tried, and what's not working.

Here is what i tried

int switchPin= 8;
int ledPin= 13;
int val;
int buttonPresses= 0;
int buttonState;

void setup() {
pinMode(switchPin,INPUT);
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
buttonState = digitalRead(switchPin);
}
void loop()
{
val = digitalRead(switchPin);
if (val !=buttonState){
if (val==LOW) {
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);
ledPin= buttonPresses;
buttonPresses--;
}
}
buttonState = val;
}

i am using an Arduino UNO and i havent settled the circuit yet

i also went through some examples but i havent seen anything similar to my homework

Ok, so what's it doing that you don't want it to do, or not doing that it should do?

the code i wrote is giving the same result as a simple blinking led. But that is not the purpose. As far as i understood, the led has to blink according to the number of time that the button is pressed. For example if i press the button 4 times, it has to be displayed in the dialog box and the led has to blink 4 times with a delay of 1sec, if the button is pressed 3 times,the led has to blink 3 times with a delay of 1sec. I understood the concept but writing it down is my problem. The code i wrote seems to be uncorrect.

incorrect*

Yeah I thought it had to count the button pushes, all the while waiting a little to see if you've stopped pushing, then flash that number of times?

So after each button push you have to increment Counter AND start a timer. Then if the timer runs for longer than required, blink the light Counter times. If another push occurs before the timer is up, the timer is reset.

I'd say you should look at the well-loved BlinkWithoutDelay example and maybe also this video.

Yes exactly. Thank you so much, i am going to start over right now and i will let you know about the result, thanks

I am not able to write the part of the counter and timer, would you mind helping me?