Controlling multiple LED in a sequence


I'm new to using an arduino and could really do with some help with getting a code for my project. I need to set up and system that when you press a button it switches on the first LED and then when pressed again the second LED then the third LED and so on until they are all switched on (I need roughly 20 in each row of LED's). I need to have a least 20 of these rows of LED's each with their own button, just wondering if anyone can help me write the code or can point me in the right direction of someone who can or the code itself.


Normally don’t post full code but this is to simple not to…

#include <Bounce2.h>

const byte LedPins[] = {3, 4, 5};//extend to all pins you want to use
const byte ButtonPin = 2; //Pin for the button, connect between pin and GND

byte ledCounter = 0;
Bounce button;

void setup(){
  //set all led pins as output
  for(byte i = 0; i < sizeof(LedPins); i++){
    pinMode(LedPins[i], OUTPUT);
  //assign ButtonPin to the debouncer
  button.attach(ButtonPin, INPUT_PULLUP);

void loop(){
  //button is pressed
    //are there still leds to turn on?
    if(ledCounter < sizeof(LedPins)){
      digitalWrite(LedPins[ledCounter], HIGH);
    //if not, turn all off and reset counter
      for(byte i = 0; i < sizeof(LedPins); i++){
        digitalWrite(LedPins[i], LOW);
      ledCounter = 0;

Uses the Bounce2 library so you have to download that :wink: