Arduino variable going blank after first pass.
- by user541597
I have an arduino sketch that takes a timet and when that timet is equal to the current time it sets the new timet to timet + 2.
For example:
    char* convert(char* x, String y){
 int hour;
 int minute;
 sscanf(x, "%d:%d", &hour, &minute);
 char buf[6];
 if (y == "6"){
 if (hour > 17){
   hour = (hour+6)%24;
   snprintf(buf, 10, "%d:%d", hour, minute );
 }else
 if (hour < 18){
   //hour = hour + 6;
   minute = (minute + 2);
   snprintf(buf, 10, "%d:%d", hour, minute);
 }
 }
 if (y == "12"){
 if (hour > 11){
   hour = (hour+12)%24;
   snprintf(buf, 10, "%d:%d", hour, minute );
 }
 else if (hour < 12){
   hour = hour + 12;
   snprintf(buf, 10, "%d:%d", hour, minute);
 }
 }
  if (y == "24"){
   hour = (hour+24)%24;
   snprintf(buf, 10, "%d:%d", hour, minute );
 }
 return buf;
}
sketch starts for example at 1:00am timet is set to 1:02, at system time 1:02 timet == system time
my loops looks like this:
if (timet == currenttime){
timet = convert(timet)
}
From this now when ever I check the value of timet it should equal 1:04, however I am getting the correct value at the first run after the execution of convert however everytime after that my timet value is blank.
I tried changing the code instead of using the if loop I only run the convert function when I send for example t through the serial monitor, this works fine and outputs the correct timet after the execution of the convert function,  So I figured the problem is in the if loop...
Any ideas?