WHAT I AM DOING WRONG....

I have 5 buttons when I push to send 1,3,5,10 impulses to the output,but when I push button sometimes work sometimes not (one of five or six tryes work).

Any help?Thanks!

int ledPin = 13; // LED is connected to digital pin 13
int switchPin1 = 2;// switch connected to digital pin 2
int switchPin2 = 3;
int switchPin3 = 4;
int switchPin4 = 5;
int switchPin5 = 6;
int switchValue; // a variable to keep track of when switch is pressed
int counter = 0;

void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
pinMode(switchPin1, INPUT); // sets the switchPin to be an input
digitalWrite(switchPin1, HIGH); // sets the default (unpressed) state of switchPin to HIGH
pinMode(switchPin2,INPUT); // sets the switchPin to be an input
digitalWrite(switchPin2, HIGH); // sets the default (unpressed) state of switchPin to HIGH
pinMode(switchPin3, INPUT); // sets the switchPin to be an input
digitalWrite(switchPin3, HIGH); // sets the default (unpressed) state of switchPin to HIGH
pinMode(switchPin4,INPUT); // sets the switchPin to be an input
digitalWrite(switchPin4, HIGH); // sets the default (unpressed) state of switchPin to HIGH
pinMode(switchPin5,INPUT); // sets the switchPin to be an input
digitalWrite(switchPin5, HIGH); // sets the default (unpressed) state of switchPin to HIGH
}

void loop() // run over and over again
{

switchValue = digitalRead(switchPin1); // check to see if the switch is pressed
if ((switchValue == LOW) && (counter <= 1)) { // if the switch is pressed then,
for(int ii = 0; ii <= 1; ii++)

{
digitalWrite(ledPin, !digitalRead(ledPin));
delay(200);
counter++;
}
}
if (switchValue == HIGH)
//if ((switchValue == HIGH) && (counter > 2))
{
counter = 0;
delay(200);

}
{

switchValue = digitalRead(switchPin2); // check to see if the switch is pressed
if ((switchValue == LOW) && (counter <= 1)) { // if the switch is pressed then,
for(int ii = 0; ii <= 3; ii++)
{
digitalWrite(ledPin, !digitalRead(ledPin));
delay(200);
counter++;
}
}
if (switchValue == HIGH)
if ((switchValue == HIGH) && (counter > 2))
{
counter = 0;
delay(200);
}

{

switchValue = digitalRead(switchPin3); // check to see if the switch is pressed
if ((switchValue == LOW) && (counter <= 1)) { // if the switch is pressed then,
for(int ii = 0; ii <= 9; ii++)

{
digitalWrite(ledPin, !digitalRead(ledPin));
delay(200);
counter++;
}
}
if (switchValue == HIGH)
//if ((switchValue == HIGH) && (counter > 2))
{
counter = 0;
delay(200);
}
{

switchValue = digitalRead(switchPin4); // check to see if the switch is pressed
if ((switchValue == LOW) && (counter <= 1)) { // if the switch is pressed then,
for(int ii = 0; ii <= 19; ii++)

{
digitalWrite(ledPin, !digitalRead(ledPin));
delay(200);
counter++;
}
}
if (switchValue == HIGH)
//if ((switchValue == HIGH) && (counter > 2))
{
counter = 0;
delay(200);
}
{

switchValue = digitalRead(switchPin4); // check to see if the switch is pressed
if ((switchValue == LOW) && (counter <= 1)) { // if the switch is pressed then,
for(int ii = 0; ii <= 19; ii++)

{
digitalWrite(ledPin, !digitalRead(ledPin));
delay(200);
counter++;
}
}
if (switchValue == HIGH)
//if ((switchValue == HIGH) && (counter > 2))
{
counter = 0;
delay(200);
}
}
}
}
}
}

WHAT I AM DOING WRONG....

SHOUTING.
Not using code tags.
Using delay() when the use of delay() is inappropriate.

      pinMode(switchPin1, INPUT);   // sets the switchPin to be an input
      digitalWrite(switchPin1, HIGH);   // sets the default (unpressed) state of switchPin to HIGH

Using digitalWrite() on an input pin does nothing to the state of the pin. It turns on the internal pullup resistor, if the value is HIGH, or turns it off if the value is LOW.

All those delay()s are what is making your code unresponsive to the switch presses.

Ive deleted code tags,digital write but its the same!What I have to do with delays?delete?
thanks a lot for helping!

Ive deleted code tags

?

You have to get rid of the calls to delay() if you want the code to be responsive - if you're in a delay(), you're not looking at switches.

The usual advice at this point is to look at the blink without delay example in the IDE, or look at Robin2's topic on doing multiple things at the same time.

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

...R

thanks a lot I will try it?