Sending values from a function to a switch statement outside of the function

Hello everyone,
I'm having a problem with my code where i try to do something like this:

switch (numh)
  {
    case 0:
      //set shift register to 01010101
      break;
    case 1:
      //set shift register to 10101010
      break;
    case 2:
       //set shift register to 11001100
      break;
}

//Something completely different

void DisplaySetHour(int numh, int i, int p)//time display function
{
  if (p == 2) //exit to main menu
 {
    menu = 0;
    menu2 == 0;
  }

  DateTime now = RTC.now(); //GETTING THE CURRENT HOUR VALUE

  if (i == 1)
  {


    if (hourupg == 23)
    {
      hourupg = 0;
      dayupg++;
    }
    else
    {
      hourupg = hourupg + 1;
    }
  }
  if (i == 2)
  {
    if (hourupg == 0)
    {
      hourupg = 23;
      dayupg--;
    }
    else
    {
      hourupg = hourupg - 1;
    }
  }

  Serial.print("Set Hours:");
  Serial.println(hourupg, DEC);
  numh = hourupg;//WRITING THE HOUR VALUE TO THE DISPLAY - DOESN'T WORK
  shifter.write();//UPDATING THE DISPLAY - DOESN'T WORK

}

The problem is that i would expect the code to send the numh value to the switch function where it gets "encoded"and displayed on the display. However, when I upload the code the number doesn't get displayed.
The end goal of this is to get a live readout on a nixie display as you adjust the values.
My full code is attached if you'd want to take a look and give me some advice.
Thank you in advance.

Nixie_Clock.ino (59.3 KB)

Welcome,

You have to call the function in which there is the switch

void setShiftRegister( uint8_t num )
{
    switch (num)
    {
        ...
    }
}

...

void DisplaySetHour(int numh, int i, int p)//time display function
{
   ...
   setShiftRegister( numh );
   ...
}

I just tried it.
Works great now.
Thank you for this advice.
Here, have some karma.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.