Button order

Hi guys, I´m having trouble with a thing a want to make.

I´m making a clock, and it has two buttons (one is set and the other is on/off).

I wana that when someone push (and keep pushing it) the buton on/off and later the set buttons it chages the hour, and when someone push the set button (and keep pushing it) and later the on/off it changes the minutes.

How will you make it. Thanks

I won't make it.

What have you tried?

There is a good library appropriately called "buttons" that can tell the difference between a long push and a short one.

https://github.com/JChristensen/Button?files=1 Maybe start there

This Thread has a simple way to deal with different button presses.

...R

I have try to make it this way

if (on_off==1){

if(set==1){ adjustTime(3600); } Code } else if (set==1){

if(on_off==1){ adjustTime(60); } Code }

But it allways changes the hours. Because of that I´m looking for help.

Tankyou guys for the information i´m going to read it now.

if (on_off==1){
  
    if(set==1){
        adjustTime(3600);
        }
}
else if (set==1){
  
    if(on_off==1){
        adjustTime(60);
        }
}

In the first part you test on_off and then test set In the second part you have it the other way round. I doubt very much if that is logical, even if the compiler does not care.

Also else if (set ==1) is not the logical opposite of if (on_off == 1) Logically they have nothing to do with each other. In fact what your ELSE clause is doing is if (on_off != 1 && set == 1)

I have no idea whether that is what you intend

...R