Thanks for the explanation! I;ve work with radio tubes before (like way back in the day) so the Anode/Cathode and High Voltage are not completely unfamiliar.
I have never worked with Nixie tubes though, so I hope I'm doing this right.
For now I'd stick with the approach I've mentioned before.
The "loop()" function is executed over and over again, so somewhere in the code there (maybe best at the beginning) we can check if minute = 0 or minute = 30.
If so then we can cycle through the numbers and when that is done, continue with the loop() code.
Note: I'm checking here if minute is either 0 or 30, and seconds=0. This to prevent that our action will be executed multiple times within a minute.
This may need some finetuning though, since I'm not 100% sure if you'd catch the exact "second = 0" moment.
Since the code is not entirely clear to me, and I have zero Nixie experience, I can only guess something like this:
if( ( (minute==0) || (minute==30) ) && (second==0) ) {
 off_all(); // all tubes OFF
on_number(row_1, nixie_0);
digitalWrite(row_1, LOW);
on_number(row_1, nixie_1);
digitalWrite(row_1, LOW);
 on_number(row_1, nixie_2);
digitalWrite(row_1, LOW);
...
on_number(row_1, nixie_9);
 digitalWrite(row_1, LOW);
 ...
on_number(row_6, nixie_0);
 digitalWrite(row_6, LOW);
on_number(row_6, nixie_1);
 digitalWrite(row_6, LOW);
on_number(row_6, nixie_2);
 digitalWrite(row_6, LOW);
 ...
on_number(row_6, nixie_9);
digitalWrite(row_6, LOW);
}
We need to do this for every row, and for every nixie. And this is just turning everything OFF, and one at a time every number ON and OFF again.
A delay between turning one ON and OFF again may be desired, I cannot imagine it to be great for the nixies to be turned on only for a fraction of a second.
Now, you do see a ton of repeated code, and this can be done much more efficient.
Â
1. I'd make row_x and nixie_y both arrays.Â
The first step what I would do is make your current code work with arrays which comes with some minor changes.
Let's start with the definition:
Replace this:
const int nixie_0 = 2;
const int nixie_1 = 3;
const int nixie_2 = 4;
const int nixie_3 = 5;Â
const int nixie_4 = 6;
const int nixie_5 = 7;
const int nixie_6 = 8;
const int nixie_7 = 9;
const int nixie_8 = 10;
const int nixie_9 = 11;
with this:
int nixies[] = {2,3,4,5,6,7,8,10,11};
NOTE: Instead of calling "nixie_0" in your code, you'd call it with "nixies[0]".
So you'd have to replace all "nixie_x" with "nixies[x]".
Same for rows, replace this:
const int row_1 = 0; // caution: constants start counting at 1, where arrays start counting at zero!
const int row_2 = 1;
const int row_3 = 14;
const int row_4 = 15;
const int row_5 = 16;
const int row_6 = 17;
with
int rows[] = {0,1,14,15,16,17};
And for rows again you'd have to replace each occurance of "row_x" with "rows[x-1]".
Note: the rows are numbered different: arrays start counting with zero, and your rows start with "1".
So the index used should be decrease by one to match the correct index (hence the "x-1").
Not required, but I'd most certainly take a look at this:
I noticed that you've hardcoded all of the numbers, instead of using the defined constants (nixie_x and row_y).
It is good practice to actually use the defined constants.
This way, if you ever have to change one of the numbers (for example because you want to use a different pin), you'd have to change it in only one place: where the constants (or array) have been defined.
For example this line (there are more) can cause problems in the long run, when you change a pin - you'd have to hunt down every "17" and replace it with the new pin number:
on_number(17,j+2);
It should probably say something like this:
on_number(row_6,j+2);
When using arrays this would be:
on_number(rows[6-1],nixies[j+2]);
This goes for pretty much all "on_number()" and "digitalWrite()" calls in your code.
(remember that your previous rows start counting at "1", whereas arrays start with "0")
After a full cleanup and a working code, you can proceed to step 2.
Â
2. I'd make a function to handle the suggested no-poisoning cycle:
void NoPoison() {
for(int r=0; r<6; r++) {
 for(int n=0; n<=9; n++) {
   on_number(r, n);
delay(100); // not sure if and how long of a delay you'd want here
  digitalWrite(r, LOW);
 }
}
}
You see that the code now has become significantly shorter and more efficient.
It occured to me though that since these are individual tubes, we can do all 6 digits in parallel, which would go faster than every individual number/tube combination.
Something like this, where we set a number for each nixie, wait a short time, and turn that number off again for each nixie.
It will go through all numbers for each nixie this way.
void NoPoison() {
int n=0; // we reuse these variables so we define them first
 int r=0;
// for every individual number:
for(n=0; n<=9; n++) {
// turn number "n" for every tube ON
 for(r=0; r<6; r++) {
   on_number(r, n);
  }
// again an arbitrary delay - up to you if you like this value
 delay(100);
// turn number "n" for every tube OFF
for(r=0; r<6; r++) {
   digitalWrite(r, LOW);
  }
}
}
Â
Â
3. Modify the loop()
No we can modify the loop to initiate the no-poison function when we hit either minute 0 or minute 30, where seconds=0.
void loop() {
if( ( (minute==0) || (minute==30) ) && (second==0) ) {
 NoPoison();
 }
 ... // the original code goes here
}
Â
Â
I realize that this may take some work, especially step 1, and I can imagine it to be a little much to comprehend or get used to.
Mind you: I do not have experience with Nixies (it is on my "todo" list haha) and I've typed all this without testing. There may be typos in it.Â