Push button with delay

Hello to all.
Im not that new to arduino but this is my first post on the forum.
Im trying to get a led to blink only for 3 seconds and then off for 10 when a button is pushed. Ive been working my way arroud and got to the point where i can blink the led for 5 seconds on and 5 off when the button is pushed, but my code doesnt seem to let me "extend" de led off state in order for my led to "delay" for 10 seconds.
Here is the code:

int inPin = 2;  // the pin number for input (for me a push button)
int ledPin = 13; 

int current;  // Current state of the button
              // (LOW is pressed b/c i'm using the pullup resistors)
int count;    // How long the button was held (secs)
byte previous = HIGH;
unsigned long firstTime;   // how long since the button was first pressed 


void setup() {
  Serial.begin(9600);         // Use serial for debugging
  pinMode(ledPin, OUTPUT);
  digitalWrite(inPin, HIGH);  // Turn on 20k pullup resistors to simplify switch input
}

void loop() {
  current = digitalRead(inPin);
  // if the button changes to pressed, remember the time 
  if (current == LOW && previous == HIGH && millis() - firstTime > 200) {
    firstTime = millis(); 
  }
  // Notice that we check if the the button has been held for at least 500 ms
  // This is to debounce the input (basically make sure we get the steady state of the button)
  if (current == LOW && ((millis() - firstTime) % 1000) < 20 && millis() - firstTime > 50){
    ledblink(1, 5000, ledPin); // Each second the button is held blink the indicator led and
    count++;                 // and add 1 to the counter
  }
  // reset the counter if the button is not pressed
  if (current == HIGH) {
    count = 0;
  }
  previous = current;
}
// Just a simple helper function to blink an led in various patterns
void ledblink(int times, int lengthms, int pinnum){
  for (int x=0; x<times;x++) {
    digitalWrite(pinnum, HIGH);
    delay (lengthms);
    digitalWrite(pinnum, LOW);
    delay(lengthms);
  }
}

Thanks!!

The code was originally obtained from the following link:
http://playground.arduino.cc/Code/HoldButton

This part of your code use the same time for ON and for OFF

void ledblink(int times, int lengthms, int pinnum) {
  for (int x = 0; x < times; x++) {
    digitalWrite(pinnum, HIGH);
    delay (lengthms);
    digitalWrite(pinnum, LOW);
    delay(lengthms);
  }

You can change it to something like

void ledblink(int times, int millisecondsON, int millisecondsOFF, int pinnum) {
  for (int x = 0; x < times; x++) {
    digitalWrite(pinnum, HIGH);
    delay (millisecondsON);
    digitalWrite(pinnum, LOW);
    delay(millisecondsOFF);
  }

And call it with

ledblink(1, 3000, 10000, ledPin);

Note that the use of long delays makes the loop unresponsive; you can do a search for 'blink without delay' to solve that.

Worked like a charm. Thanks for you advice on the blink without delay function. Ill look it up.
Here is the final code.

Sudo

int inPin = 2; // the pin number for input (for me a push button)
int ledPin = 13;

int current; // Current state of the button
// (LOW is pressed b/c i'm using the pullup resistors)
int count; // How long the button was held (secs)
byte previous = HIGH;
unsigned long firstTime; // how long since the button was first pressed

void setup() {
Serial.begin(9600); // Use serial for debugging
pinMode(ledPin, OUTPUT);
digitalWrite(inPin, HIGH); // Turn on 20k pullup resistors to simplify switch input
}

void loop() {
current = digitalRead(inPin);
// if the button changes to pressed, remember the time
if (current == LOW && previous == HIGH && millis() - firstTime > 200) {
firstTime = millis();
}
// Notice that we check if the the button has been held for at least 500 ms
// This is to debounce the input (basically make sure we get the steady state of the button)
if (current == LOW && ((millis() - firstTime) % 1000) < 20 && millis() - firstTime > 50){
ledblink(1, 3000, 10000, ledPin); // Each second the button is held blink the indicator led and
count++; // and add 1 to the counter
}
// reset the counter if the button is not pressed
if (current == HIGH) {
count = 0;
}
previous = current;
}
// Just a simple helper function to blink an led in various patterns
void ledblink(int times, int millisecondsON, int millisecondsOFF, int pinnum) {
for (int x = 0; x < times; x++) {
digitalWrite(pinnum, HIGH);
delay (millisecondsON);
digitalWrite(pinnum, LOW);
delay(millisecondsOFF);
}
}

when the relay is on while i press push button it will be turned off also vice versa

Look at the StateChangeDetection example in the IDE.

kuseidos:
Worked like a charm. Thanks for you advice on the blink without delay function. Ill look it up.
Here is the final code.

Sudo

int inPin = 2; // the pin number for input (for me a push button)
int ledPin = 13;

int current; // Current state of the button
// (LOW is pressed b/c i'm using the pullup resistors)
int count; // How long the button was held (secs)
byte previous = HIGH;
unsigned long firstTime; // how long since the button was first pressed

void setup() {
Serial.begin(9600); // Use serial for debugging
pinMode(ledPin, OUTPUT);
digitalWrite(inPin, HIGH); // Turn on 20k pullup resistors to simplify switch input
}

void loop() {
current = digitalRead(inPin);
// if the button changes to pressed, remember the time
if (current == LOW && previous == HIGH && millis() - firstTime > 200) {
firstTime = millis();
}
// Notice that we check if the the button has been held for at least 500 ms
// This is to debounce the input (basically make sure we get the steady state of the button)
if (current == LOW && ((millis() - firstTime) % 1000) < 20 && millis() - firstTime > 50){
ledblink(1, 3000, 10000, ledPin); // Each second the button is held blink the indicator led and
count++; // and add 1 to the counter
}
// reset the counter if the button is not pressed
if (current == HIGH) {
count = 0;
}
previous = current;
}
// Just a simple helper function to blink an led in various patterns
void ledblink(int times, int millisecondsON, int millisecondsOFF, int pinnum) {
for (int x = 0; x < times; x++) {
digitalWrite(pinnum, HIGH);
delay (millisecondsON);
digitalWrite(pinnum, LOW);
delay(millisecondsOFF);
}
}

Can anyone help me to modify same code but function
will be

initial start will be turn off led, on push button it will delay 10 sec and the led will be on until push off, if push button off it will timidity turn off the led.

no blinking...

please help... i am no a coder or programmer just a novice.

alaminxp:
initial start will be turn off led, on push button it will delay 10 sec and the led will be on until push off, if push button off it will timidity turn off the led.

Please rephrase your requirement; something in a style like
1)
led off
2)
if button not pushed, back to (2)
3)
wait 10 seconds
4)
led on
5)
if button not pushed, back to (5)
6)
back to (1)