pushbutton counter help

Hi,
base on the example file of pushbotton and led
I need help on adding different led sequence base on push of botton
example 1 push 3 led blink
second push leds go off
third push second animation goes gon
4th push second animation off
5th push 3th animation on
6th push 3th animation off

any sugestion is very welcome

/// code here////

// this constant won't change:
const int buttonPin = 1; // the pin that the pushbutton is attached to

const int ledPin4 = 4;
const int ledPin5 = 5;
const int ledPin6 = 6;
const int ledPin7 = 7;

const int ledPin8 = 8; // the pin that the LED is attached to
const int ledPin9 = 9;
const int ledPin10 = 10;

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6 , OUTPUT);
pinMode(ledPin7 , OUTPUT);
pinMode(ledPin8, OUTPUT);
pinMode(ledPin9, OUTPUT);
pinMode(ledPin10 , OUTPUT);
// initialize serial communication:

}

void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;

}
else {
// if the current state is LOW then the button
// wend from on to off:

}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;

// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter == 1) {
digitalWrite(ledPin8, HIGH);
} else {
digitalWrite(ledPin8, LOW);
}

if (buttonPushCounter == 2) {

digitalWrite(ledPin8, HIGH);
delay(100);
digitalWrite(ledPin8, LOW);

digitalWrite(ledPin9, HIGH);
delay(100);
digitalWrite(ledPin9, LOW);

digitalWrite(ledPin10, HIGH);
delay(100);
digitalWrite(ledPin10, LOW);

} else {
digitalWrite(ledPin8, LOW);
digitalWrite(ledPin9, LOW);
digitalWrite(ledPin10, LOW);
}

if (buttonPushCounter == 3) {

digitalWrite(ledPin8, HIGH);
delay(100);
digitalWrite(ledPin8, LOW);

digitalWrite(ledPin9, HIGH);
delay(100);
digitalWrite(ledPin9, LOW);

} else {
digitalWrite(ledPin8, LOW);
digitalWrite(ledPin9, LOW);
digitalWrite(ledPin10, LOW);
}

/////END OF CODE/////
}

what is your question or problem?

thanks Naruto128
my questions is how to implement

4 kinds of animations that change with a push of a botton. each time the botton is press a new animation will run

working in my problem
here is the new code

no my questions is how can I reset the count after the fourth push botton count.

// this constant won't change:
const int buttonPin = 1; // the pin that the pushbutton is attached to
const int ledPin8 = 8; // the pin that the LED is attached to
const int ledPin9 = 9; // the pin that the LED is attached to
const int ledPin10 = 10; // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
pinMode(ledPin8, OUTPUT);
pinMode(ledPin9, OUTPUT);
pinMode(ledPin10, OUTPUT);
// initialize serial communication:

}

void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;

}
else {
// if the current state is LOW then the button
// wend from on to off:

}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;

// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter == 1) {
digitalWrite(ledPin8, HIGH);
} else {
digitalWrite(ledPin9, LOW);
}

if (buttonPushCounter == 2) {
digitalWrite(ledPin9, HIGH);
} else {
digitalWrite(ledPin9, LOW);
}

if (buttonPushCounter == 3) {
digitalWrite(ledPin10, HIGH);
} else {
digitalWrite(ledPin10, LOW);
}

if (buttonPushCounter >= 4) {
digitalWrite(ledPin8, HIGH);
} else {
digitalWrite(ledPin8, LOW);
}

}

if (buttonPushCounter >= 4) {
digitalWrite(ledPin8, HIGH);
} else {
digitalWrite(ledPin8, LOW);
}

if( buttonPushCounter>=4){

buttonPushCounter=0;
}

See if you get anything out this -

const uint8_t   pushButtonPin   =  2;

struct button_t
{
    const uint8_t   _pin;
    
    uint8_t         _count;
    uint8_t         _statePrevious;
};

button_t        button = { pushButtonPin,  0, LOW };

uint8_t button_count(struct button_t* pButton)
{
    uint8_t     state;

    state = digitalRead(pushButtonPin);
    if ( state != pButton->_statePrevious )
    {
        if ( state == HIGH )
        {
            pButton->_count++;
        }
    }

    pButton->_statePrevious = state;
    
    return pButton->_count;
}

void funct2(void)   {}
void funct1(void)   {}
void funct0(void)   {}

void loop()
{
    switch ( button_count(&button) )
    {
        case 0:
            // ... bever pressed, or was 'reset' ...
            funct0();
            break;

        case 1:
            // ... pressed once ...
            funct1();
            break;

        case 2:
            // ... pressed twice ...
            funct2();
            break;

        // ... more as required ...

        default:
            // ... if not a handled 'case' reset 'button's '_count'er value ...
            button._count = 0;
            break;
    }
}

void setup()
{
    pinMode(button._pin, INPUT);
}

thanks !!
it works
now the glitch is that I have to wait for the long loop fo finish then push the botton to change animation.
I am working with a attiny2313 set with internal clock at 1hrz ( default)

here is code if some can can point me to the direction of fixing that glitch

const uint8_t pushButtonPin = 1;

struct button_t
{
const uint8_t _pin;

uint8_t _count;
uint8_t _statePrevious;
};

button_t button = { pushButtonPin, 0, LOW };

uint8_t button_count(struct button_t* pButton)
{
uint8_t state;

state = digitalRead(pushButtonPin);
if ( state != pButton->_statePrevious )
{
if ( state == HIGH )
{
pButton->_count++;
}
}

pButton->_statePrevious = state;

return pButton->_count;
}

void funct2(void) {}
void funct1(void) {}
void funct0(void) {}

// this constant won't change:
const int buttonPin = 1; // the pin that the pushbutton is attached to
const int ledPin4 = 4; // the pin that the LED is attached to
const int ledPin5 = 5; // the pin that the LED is attached to
const int ledPin6 = 6; // the pin that the LED is attached to
const int ledPin7 = 7; // the pin that the LED is attached to
const int ledPin8 = 8; // the pin that the LED is attached to
const int ledPin9 = 9; // the pin that the LED is attached to
const int ledPin10 = 10; // the pin that the LED is attached to
const int ledPin11 = 11; // the pin that the LED is attached to

void setup()
{
pinMode(pushButtonPin, INPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin8, OUTPUT);
pinMode(ledPin9, OUTPUT);
pinMode(ledPin10, OUTPUT);
pinMode(ledPin11, OUTPUT);
}

void loop()
{
switch ( button_count(&button) )
{
case 0:
// ... bever pressed, or was 'reset' ...
funct0();
digitalWrite(ledPin8, HIGH);
break;

case 1:
// ... pressed once ...
funct1();

digitalWrite(ledPin9, HIGH);
delay(100);
digitalWrite(ledPin9, LOW);
delay(100);
digitalWrite(ledPin8, HIGH);
delay(100);
digitalWrite(ledPin8, LOW);
delay(100);
digitalWrite(ledPin11, HIGH);
delay(100);
digitalWrite(ledPin11, LOW);
delay(100);

digitalWrite(ledPin10, HIGH);
delay(100);
digitalWrite(ledPin10, LOW);
delay(100);

break;

case 2:
// ... pressed twice ...
funct2();

digitalWrite(ledPin4, HIGH);
delay(100);
digitalWrite(ledPin4, LOW);
delay(100);

digitalWrite(ledPin5, HIGH);
delay(100);
digitalWrite(ledPin5, LOW);
delay(100);

digitalWrite(ledPin6, HIGH);
delay(100);
digitalWrite(ledPin6, LOW);
delay(100);

digitalWrite(ledPin7, HIGH);
delay(100);
digitalWrite(ledPin7, LOW);
delay(100);

digitalWrite(ledPin8, HIGH);
delay(100);
digitalWrite(ledPin8, LOW);
delay(100);

digitalWrite(ledPin9, HIGH);
delay(100);
digitalWrite(ledPin9, LOW);
delay(100);

digitalWrite(ledPin10, HIGH);
delay(100);
digitalWrite(ledPin10, LOW);
delay(100);

digitalWrite(ledPin11, HIGH);
delay(100);
digitalWrite(ledPin11, LOW);
delay(100);

break;

// ... more as required ...

default:
// ... if not a handled 'case' reset 'button's '_count'er value ...
button._count = 0;
break;
}
}

First off, post code in code tags.

As far as getting your buttons to be more responsive, you'll need to rewrite your blinking code to be non blocking. That means getting rid of all the delays. The BlinkWithoutDelay example demonstrates the basic concepts that act as the building blocks for this technique.