Multiple LED with one button

Hi everyone! I am trying to make an Arduino automatic door control which has eight timer modes of closing the door. For example: First mode will close the door after 30 sec, second after 60, third after 120 etc… These modes need to be set via 2 buttons (one seting timer UP- adding time, other DOWN decreasing the time mode) and 8 LEDs each indicating each mode.
I manage to make modes increasing by pressing the first button, but there is a problem when I need to decrease…

pls Help! I am new to Arduino and programming in general.

automatic door control.ino (5.29 KB)

but there is a problem when I need to decrease...

Which is?

pls Help!

What help do you need? Other than with spelling?

                if (Mode == 1) {          
                Mode = 2;               
            } else {
                if (Mode == 2) {        
                Mode = 3;           
            } else {
                if (Mode == 3) {      
                Mode = 4;           
            } else {
                if (Mode == 4) { 
                Mode = 5;          
            } else {
                if (Mode == 5) {
                Mode = 6;
            } else {
                if (Mode == 6) {
                Mode = 7;
            } else {
                if (Mode == 7) {
                Mode = 8;
             } else {
                if (Mode == 8) {
                Mode = 1;
            }

That's ridiculous.

  Mode++;
  if(Mode == 8)
     Mode = 1;

Way simpler.

it doesn't react, only showing the mode 8...the code is in the attachment... It works well for first button and increasing the time modes, but when I try to decrease I get all 8 LEDs on... :slight_smile:

I know :slight_smile: thank you Paul!

You only ever turn LEDs on you never turn any off. Once you hit mode 8 all your leds will be on no matter what mode you go to.

Whenever you have variable names that are numbered you probably need to use an array. This sketch would really benefit from arrays.