4LEDs 2 buttons Need HELP!!

I'm new to this so any assistance is appreciated. This is what i'm wanting to do I want to push button 1 (up) one time and light up led 1 then press it again and light up led 1 and 2 press it 3 times lights up 3 leds and press it for the fourth time lights up led 4. Then with button 2(down) I want to be able to press it back it off one led. For example I have 3 leds lit I push the down button now i have 2 leds lit, I push up button I have 3 leds lit. I've tried taking different codes and putting them together to try and make it work with no success.

Post your parts.
Post your schematic.
Post your code.

With that, we can help you get it working.

You'll get help more readily if you post the code you have tried so far, even though it's not working. You should also say what it is doing, and not doing. Also better if you include a schematic or Fritzing pic.

Have you looked at this tutorial and also this one?

I tried putting in the code but it says I exceeded the maximum allowed length

  const int ledPins[] = {2,3,4,5}; 
const int buttonPin = 11;    
const int buttonPin2 = 10;      

int lastCounter = 4;
int counter;             
int up;
int down;

int buttonPushCounter = 0;                                                      
int buttonState = 0;    
int lastButtonState = 0;  

int buttonPushCounter2 = 0;                                                                     
int buttonState2 = 0;     
int lastButtonState2 = 0;   



void setup() {
  
  for(int i = 0; i < 4; i++){     
      pinMode(ledPins[i],OUTPUT);
  }                                  
  
 

  pinMode(buttonPin, INPUT); 
  pinMode(buttonPin2, INPUT);
  Serial.begin(9600);
 }
 
 
void loop(){  
  counter = lastCounter; 

  buttonState = digitalRead(buttonPin);
  buttonState = digitalRead(buttonPin2);
        
  if (buttonState != lastButtonState) {      
          
          if (buttonPin == HIGH) {  
             buttonPushCounter++;
             counter = counter+1; 
             Serial.println("Counter");
             Serial.println(counter);
          }  
          
          if (buttonPin2 == HIGH) {
             buttonPushCounter++;
             counter = counter-1;
             Serial.println("Counter");
             Serial.println(counter);
          } 
          else {

            Serial.println("off"); 
          }
        }

          lastButtonState = buttonState;
:
          if (buttonPushCounter % 2 == 0) {
     

        
                delay(300); 
        }
  if (counter > 5){    
    counter = 5;
  }
  
  if (counter < 2){    
    counter = 1;
  }
                           
  switch(counter){
    
    
  case 1:
  SEQ1();
  break;
  case 2:
  SEQ2();  
  break;
  case 3:
  SEQ3(); 
  break;
  case 4:
  SEQ4();
  break;
  
        
  }
                             
                             
}
 

void SEQ1(){
  int delayTime = 100;
                    
  digitalWrite(ledPins[0], HIGH); 
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[1], LOW); 
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[2], LOW); 
  button_delay(delayTime, buttonPin);           
  digitalWrite(ledPins[3], LOW);
  button_delay(delayTime, buttonPin);            

//Turns Each LED Off
  digitalWrite(ledPins[3], LOW);
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[2], LOW); 
  button_delay(delayTime, buttonPin);          
  digitalWrite(ledPins[1], LOW);
  button_delay(delayTime, buttonPin);       
  digitalWrite(ledPins[0], LOW);
  delay(delayTime);              
  
}
 

void SEQ2(){
  int delayTime = 100; 
  digitalWrite(ledPins[0], HIGH);
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[1], HIGH); 
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[2], LOW);  
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[3], LOW); 
  button_delay(delayTime, buttonPin);             

//Turns Each LED Off
  digitalWrite(ledPins[3], LOW); 
  button_delay(delayTime, buttonPin);               
  digitalWrite(ledPins[2], LOW); 
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[1], LOW); 
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[0], LOW);  
  delay(delayTime);               
  
}


void SEQ3(){
  int delayTime = 100;
  digitalWrite(ledPins[0], HIGH);  
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[1], HIGH);  
  button_delay(delayTime, buttonPin);               
  digitalWrite(ledPins[2], HIGH);
  button_delay(delayTime, buttonPin);                
  digitalWrite(ledPins[3], LOW);  
  button_delay(delayTime, buttonPin);                

//Turns Each LED Off
  digitalWrite(ledPins[3], LOW); 
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[2], LOW);  
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[1], LOW);  
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[0], LOW);  
  delay(delayTime);             
  
}


void SEQ4(){
  int delayTime = 100;
  digitalWrite(ledPins[0], HIGH); 
  button_delay(delayTime, buttonPin);             
  digitalWrite(ledPins[1], HIGH);  
  button_delay(delayTime, buttonPin);               
  digitalWrite(ledPins[2], HIGH);  
  button_delay(delayTime, buttonPin);                
  digitalWrite(ledPins[3], HIGH);  
  button_delay(delayTime, buttonPin);                

//Turns Each LED Off
  digitalWrite(ledPins[3], LOW);  
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[2], LOW); 
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[1], LOW); 
  button_delay(delayTime, buttonPin);              
  digitalWrite(ledPins[0], LOW);  
  delay(delayTime);               
  
}


void button_delay(int msec, int btnpin) 
{
  int btnstate = 0;       
  btnstate = digitalRead(btnpin);
  if(btnstate == HIGH)
  {
    delay(msec);
    
    lastCounter = counter;
  }
  
}

The way the LEDs are wired up writing a LOW to them turns them on and a HIGH turns them off. Are the LEDs the right way round? Try the blink sketch on them to see if it is working.

You don't say what is wrong just that it dosen't work. Can you be more specific about what you get on the serial monitor.

When I hold down the first button (up) it will light one LED then delay for delayTime ten light the next LED until all LEDs are on it will then turn them off one after another and just keeps repeating itself. Until I let off the button. When I hold it down again it does the same thing nothing different. And the second button (down) does nothing. I pulled up the serial monitor and the only thing that shows up is when I push the second button (down) it shows off.

Yeah, you've got some problems in your code.

Try this. It should get you closer. If it doesn't work, at least look at the changes to try to understand where your problems are.

void loop()
{  
 // counter = lastCounter; // what is this for?

  buttonState = digitalRead(buttonPin);
  buttonState2 = digitalRead(buttonPin2);
        
  if (buttonState != lastButtonState) 
  {      
      if (buttonState == HIGH) 
      {  
         buttonPushCounter++;
         counter = counter+1; 
         Serial.println("Got Up. Counter:");
         Serial.println(counter);
      }
      
    lastButtonState = buttonState;
  }

  if (buttonState2 != lastButtonState2) 
  {      
      if (buttonState2 == HIGH) 
      {
         buttonPushCounter++;
         counter = counter-1;
         Serial.println("Got Down. Counter:");
         Serial.println(counter);
      } 
      
      lastButtonState2 = buttonState2;
   }

   if (buttonPushCounter % 2 == 0) 
   {
       delay(300); 
   }
   
   if (counter > 5)
   {    
      counter = 5;
   }
  
   if (counter < 2)
   {    
        counter = 1;
   }
                           
   switch(counter)
   {
    case 1:
        SEQ1();
        break;
    case 2:
        SEQ2();  
        break;
    case 3:
        SEQ3(); 
        break;
    case 4:
        SEQ4();
        break;
  }
}

That got me closer!!! :smiley: What it is doing now is when I hold down button one (up) first press it lights up the first one. Second press lights up 1 and 2. Third press lights up 1,2, and 3. Fourth press lights up 1,2,3, and 4. Button 2 (down) when pressed does not light up any LEDs but while holding down button one (up) and pressing button 2 (down) it decreases the LEDs. So we are on the right track. Thank you so much!! I deleted all the delay's between the LEDs and deleted the turn off LEDs and it is working like I wanted it to. Now the lights stay on. I push the up button and the next LED lights up and I don't have to hold it down. I push the down button and it turns off one led. I'm building a flight simpit and one of the controls is a 4 position switch and i'm going to use this as a indicator to show me what position the switch is at.

Oh yeah, so OK, I don't know what your SEQ() things do, but basically, as you turn on the next light, you also need to turn off the previous light. That should fix the problem for both up and down. Down is actually working, but because UP didn't turn the lights off, you can't see DOWN turning them on.