" led off delay" ?? Help needed, Newbie :smiley-sweat:

Hi, great to be around so many wise guys and girls :)

well lets take this botton sketch:

const int buttonPin = 2; const int ledPin = 5; int buttonState = 0;

void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); }

void loop(){ buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } }

I would like ti turn the led on and off, but if it was on for over 10 sec it will automaticly turn off. does any one know how to approach that task? or have some code exambles. Ive tryed to google many tings, but all of what i found was way to advarnced

(deleted)

i can kind of see your ideer, but i can not se how
I found this on the internet, but cant put it together…

for(int x =0;x<500;x++)
{
delay(10);
if(digitalRead(button)==ON || x == 499)
{
digitalWrite(led)=OFF;
break;
}
}