Cant find where is the problem when i want to set the Hours for an alarm clock

I think the problem is somewhere here …When i want to adjust time with buttons it always says 00 and doesnt do anything.

void transition(int trigger)
{
switch (state)
{
case MAIN:
if (trigger == btnMENU)
{
lcd.clear();
state = MENU_SET_TIME;
}
break;

case MENU_SET_TIME:
if (trigger == btnUP)
{
lcd.clear();
state = MENU_SET_DATE;
}

if (trigger == btnMENU)
{
lcd.clear();

state = SET_HOUR;
}
if (trigger == btnBACK)
{
lcd.clear();
state = MAIN;
}
break;

case MENU_SET_DATE:

if (trigger == btnDOWN)
{
lcd.clear();
state = MENU_SET_TIME;
}

if (trigger == btnMENU)
{
lcd.clear();
state = SET_DAY;

}
if (trigger == btnBACK)
{
lcd.clear();
state = MAIN;
}
break;

case SET_HOUR:
if (trigger == btnUP)
{
Hour++;
if (Hour>23) Hour = 0;
}
else if (trigger == btnDOWN)
{
Hour–;
if (Hour<0) Hour = 23;
}
if (trigger == btnMENU)
{
state = SET_MINUTE;
}
break;
case SET_MINUTE:
if (trigger == btnUP)
{
Minute++;
if (Minute>59) Minute = 0;
}
else if (trigger == btnDOWN)
{
Minute–;
if (Minute<0) Minute = 59;
}

if (trigger == btnBACK)
{

state = SET_HOUR;
}
if (trigger == btnMENU)
{

set_time();
lcd.clear();
lcd.setCursor(4,0);
lcd.print(“Time Set!”);
delay(1000);

lcd.clear();
state = MAIN;
}
break;

case SET_DAY:
if (trigger == btnUP)
{
Day++;
if (Day>31) Day = 1;
}
else if (trigger == btnDOWN)
{
Day–;
if (Day<1) Day = 31;
}
if (trigger == btnMENU)
{
state = SET_MONTH;
}
break;
case SET_MONTH:
if (trigger == btnUP)
{
Month++;
if (Month>12) Month = 1;
}
else if (trigger == btnDOWN)
{
Month–;
if (Month<1) Month = 12;
}
if (trigger == btnMENU)
{
state = SET_YEAR;
}
if (trigger == btnBACK)
{

state = SET_DAY;
}
break;
case SET_YEAR:
if (trigger == btnUP)
{
Year++;
if (Year>99) Year = 0;
}
else if (trigger == btnDOWN)
{
Year–;
if (Year<0) Year = 99;
}
if (trigger == btnBACK)
{

state = SET_MONTH;
}
if (trigger == btnMENU)
{
set_date();
lcd.clear();
lcd.setCursor(4,0);
lcd.print(“Date Set!”);
delay(1000);
lcd.clear();
state = MAIN;
}
break;
}
}

You have posted a snippet of code. It is unlikely that the problem is actually in the snippet. Please post your code using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpreted by the forum code as italics or funny emoticons.

Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. Or perhaps open it in WordPad, which isn't very good for looking at code. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.

Apart from posting all the code you should probably investigate the behaviour of the program by using Serial.Print. That way you can see exactly what the program is doing...

using-the-print-function-with-arduino-part

well you do modify the Minute and Hour variables in there but you never display them. is that handled in the main code?

also make sure that Minute and Hour are not unsigned int or bytes because they will never go negative and then

if (Minute<0) Minute = 59;

would never happen as you would go from 0 to 255 and not -1 if you are using bytes (byte stores an 8-bit unsigned number, from 0 to 255 when you remove 1) or from 0 to 65,535 when you remove 1.

Not being able to see the whole code makes it difficult to tell you what is not working. please post the whole thing if you want more help.