controlling multiple leds with multiple push buttond

Hey i am a newbie i want to use this program to control many leds with many push button. I have written a program to control 2 led with 2 push button please help me getting this program worked.

int ledPin1 = 3;
int ledPin2 = 2;
int switchPin1=0;
int switchPin = 1;
int count = 0;
boolean lastButton;
boolean lastButton1;
boolean currentButton1=false;
boolean currentButton = false;
int ctr=0;

void setup() {
pinMode(switchPin1, INPUT);
pinMode(switchPin , INPUT);
pinMode(ledPin1, OUTPUT);

count = 0;
ctr=0;
}
//debounce function to stabilise the button
boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
boolean current1 = digitalRead(switchPin1);
if (last != current || current1)
{
delay(5);
current = digitalRead(switchPin);
current1=digitalRead(switchPin1);
}
return current;
return current1;
}
void loop() {
lastButton = currentButton;
currentButton = debounce(lastButton);
if ( lastButton == false && currentButton == true)
{
if (count == 0)
{

count++;
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);

}

else if (count == 1)
{

count=0;
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}

}

lastButton1 = currentButton1;
currentButton1 = debounce(lastButton1);
if ( lastButton1 == false && currentButton1 == true)
{
if (ctr == 0)
{

ctr++;
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1, LOW);

}

else if (count == 1)
{

ctr=0;
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin1, LOW);
}

}
}

sketch_dec31a.ino (1.45 KB)

The code in several things at a time uses a switch to toggle an LED. It would be easy to extend.

...R

You need to put your code inside code tags. When you are in the edit window and above is the smiley faces.. above that hold the mouse over the :neutral_face: and find the one that tool tip says CODE and give it a click.

and the words code and /code in brackets will appear but look like this posted

You have a function boolean debounce(boolean last) with TWO returns! No! You defined ONE as return.

I have a small library that lets users make led and button code objects and arrays of objects.
The led objects can be on/off/blink with settable time in millis. Time == 0 stops the blink.
The button objects can be read for state == undecided, previously off, previously on, just off, just on.
With button object read state, you don't even need to keep track of the last read. 3 is sw-off-to-on.

I have an example for 4 buttons (jumper wires) and led 13 on an Uno.

I think that you might need more of both.