I’m working on a Nixie clock, and thankfully i’ve got the clock itself working fine. I’m trying to implement a cathode poisoning prevention routine, basically I need to cycle all the digits in all the tubes every 5-10 minutes or so. This is proving to be a bigger challenge than anticipated.

The code is not consistent, it doesn’t consistently recognize that the minutes one’s digit is a 5 or 0. More importantly though, is that if it does recognize a 5 or 0 sometimes only the ones digit will cycle, other times all digits will cycle indefinitely, yet others nothing will happen.

Any ideas?

```
void CATHODE_POISONING_PREVENTION(){
rtc.getTime(); //Get the current I2C time
int Ones = int(t.min); //Cast the minutes time into an int
int HOURS = int(t.min); //Cast the minutes time into an int
int ONES_DIGIT = Ones%10; //Get the ones digit
int START_MILLIS = millis(); //Store the time before the loop starts.
int MIN_ONES = 0; //Create variables for loop.
int MIN_TENS = 0;
int HOURS_ONES = 0;
int HOURS_TENS = 0;
int DTIME = 250; //Variable to try different delay times.
if((ONES_DIGIT != LAST_MINS)){ //Run if the current ones digit is not equal to the last time this was run.
//Only runs once per minute.
if(ONES_DIGIT == 0 || ONES_DIGIT == 5){ //Only run every 5 minutes, when ones digit is 0 or 5.
Serial.print("CATHODE POISONING AT "); //Printing this to check if the if statement is being run.
Serial.println(rtc.getTimeStr());
while(millis() < (START_MILLIS + 5000)){ //Run this loop for 5 seconds
MIN_ONES = random(0,9); //Pick a random number
if(millis() > (START_MILLIS + DTIME)){ //Wait one delay time then start random number
MIN_TENS = random(0,9);}
if(millis() > (START_MILLIS + 2*DTIME)){ //Wait two delay time then start random number
HOURS_ONES = random(0,9);}
if(millis() > (START_MILLIS + 3*DTIME)){ //Wait three delay time then start random number
HOURS_TENS = random(0,9);}
WRITE_TUBE(MIN_ONES, MIN_TENS,1); //Write data to tubes.
WRITE_TUBE(HOURS_ONES, HOURS_TENS,2);
delay(75);} //Delay so number change is visible.
LAST_MINS = ONES_DIGIT;} //Set LAST_MINS global to the current ones digit.
}
}
```