<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Nixie Clock - How can i add my desired function to this code - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 09 Jun 2026 02:10:12 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/paged/2/#post-3211</link>
                        <pubDate>Wed, 10 Mar 2021 12:31:25 +0000</pubDate>
                        <description><![CDATA[Ah we are making progress 😁 
Although I&#039;m not seeing why the clock stops after a NoPoison ... 
Note:
One thing I had not considered in the previous code, is the time it takes to run NoPoi...]]></description>
                        <content:encoded><![CDATA[<p>Ah we are making progress 😁 </p>
<p>Although I'm not seeing why the clock stops after a NoPoison ... </p>
<p>Note:</p>
<p>One thing I had not considered in the previous code, is the time it takes to run NoPoison. <br />To compensate for that we should maybe read the time again after doing NoPoison.<br />This should have no impact on the clock that stops working.</p>
<p>I also realized that when setting the time on your clock, the NoPoison may screw that up.<br />So I added "<strong>(mode_step==0)</strong>" to make sure we are in "regular time mode", and not in "setting the time mode".</p>
<p>Replace this part, where we call NoPoison in void loop():</p>
<pre contenteditable="false">    // --- Trigger NoPoison every half hour
    if( ( (minute==0) || (minute==30) ) &amp;&amp; (second==0) ) {
      NoPoison();
    }</pre>
<p> </p>
<p>with this  (added mode_step check, AllOff, and reading time again):</p>
<pre contenteditable="false">    // --- Trigger NoPoison every half hour
    if( ( (minute==0) || (minute==30) ) &amp;&amp; (second==0) &amp;&amp; (mode_step==0)) {
      NoPoison();
      AllOff();

      // Read time again
      DateTime now = RTC.now();
      hour = now.hour();
      minute = now.minute();
      second = now.second();
    }</pre>
<p> </p>
<p>I highly doubt this will fix the issue you're seeing though.</p>
<p>As far as I can see, the numbers should appear as before. Before NoPoison runs, the clock works correctly right?</p>
<p>From what I get from the code is that there is always at the most 1 nixie ON showing at the most one number.<br />The switching between tubes goes fast enough that the user doesn't see the tubes going off in between.<br />The code suggests the numbers will be set each time we run though void loop().</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/paged/2/#post-3211</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/paged/2/#post-3210</link>
                        <pubDate>Wed, 10 Mar 2021 11:27:19 +0000</pubDate>
                        <description><![CDATA[@hans thank you for saving me from confusion this time it partially worked whenever it reaches 0 or 30 minutes it cycles thorough numbers with a crazy speed but unfortunately after that the ...]]></description>
                        <content:encoded><![CDATA[<p>@hans thank you for saving me from confusion this time it partially worked whenever it reaches 0 or 30 minutes it cycles thorough numbers with a crazy speed but unfortunately after that the clock stops working like it should and only 2 last digits of clock are glowing while they are not working and they are stuck and frozen besides that it kinda works , im not expert in coding maybe when arduino sees the condition after doing wha we asked it to do doesnt know what to do next , do you know what i mean? while its not 0 or 30 minutes it is an ordinary clock , but when it meets the 0  or 30 condition it should show us an animation of numbers but does it understand after animation it should become lock again?</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>pejman1998</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/paged/2/#post-3210</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3195</link>
                        <pubDate>Mon, 08 Mar 2021 11:45:16 +0000</pubDate>
                        <description><![CDATA[No problem!
I&#039;ve merged all of it in one sketch (I hope I didn&#039;t miss anything).I tried compiling it and it did not give me any error messages, so it all looks good.
Give it a try ...
I&#039;v...]]></description>
                        <content:encoded><![CDATA[<p>No problem!</p>
<p>I've merged all of it in one sketch (I hope I didn't miss anything).<br />I tried compiling it and it did not give me any error messages, so it all looks good.</p>
<p>Give it a try ...</p>
<p>I've also attached it as a downloadable INO file:</p>
161
<p> </p>
<pre contenteditable="false">#include &lt;Wire.h&gt;
#include "DS3231.h"

RTClib RTC;
DS3231 Clock;

int hour;
int minute;
int second;

// arrays with the pins for the rubes and the digits
int Digits[] = {2,3,4,5,6,7,8,9,10,11};
int NixieTubes[] = {0,1,14,15,16,17};

const int button_up = 12;
const int button_dn = 13;

int button_up_value;
int button_dn_value;

boolean hour_blink, min_blink, sec_blink;
int blink_latch = 0;
int mode_step = 0;
int mode_counter = 0;
int change_counter = 0;

const int time_on = 2;  //time display each number of nixie tube

void setup() {
  for(int Counter=0; Counter&lt;=9; Counter++) {
    pinMode(NixieTubes, OUTPUT);
  }
  
  for(int Counter=0; Counter&lt;6; Counter++) {
    pinMode(Digits, OUTPUT);
  }

  pinMode(button_up, INPUT_PULLUP);
  pinMode(button_dn, INPUT_PULLUP);

  Wire.begin();

  hour_blink = false;
  min_blink = false;
  sec_blink = false;
}

void loop() {
    //-------------------get clock value---------------------------
    DateTime now = RTC.now();
    hour = now.hour();
    minute = now.minute();
    second = now.second();

    // --- Trigger NoPoison every half hour
    if( ( (minute==0) || (minute==30) ) &amp;&amp; (second==0) ) {
      NoPoison();
    }
      
    //-------------------show clock number ----------------------
    int j; //second number from right
    int k; //first number from right

    //-----------------------------------------------------------------------second number show
    j = second/10;
    k = second%10;

    if(sec_blink==false)
    {
      //-----------show first number of second
      AllOff();
      NumberON(0,k+2);
      delay(time_on);

      //-----------show second number of second
      AllOff();
      NumberON(1,j+2);
      delay(time_on);
    }
    else 
    {
      if(blink_latch &lt; 8){  //blink_latch: time for blinking
        AllOff();
        delay(time_on);
        blink_latch++;
      }
      else 
      {
        //-----------show first number of second/ blink display
        AllOff();
        NumberON(0,k+2);
        delay(time_on);

        //-----------show second number of second/ blink display
        AllOff();
        NumberON(1,j+2);
        delay(time_on);
        if (blink_latch &lt; 16) blink_latch++;
        else blink_latch = 0;
      }
    }

    //-------------------------------------------------------------minute number show
    j = minute/10;
    k = minute%10;

    if(min_blink==false)
    {
      //-----------show first number of minute
      AllOff();
      NumberON(14,k+2);
      delay(time_on);
      //-----------show second number of minute
      AllOff();
      NumberON(15,j+2);
      delay(time_on);
    }
    else
    {
      if(blink_latch &lt; 8){  //blink_latch: time for blinking
        AllOff();
        delay(time_on);
        blink_latch++;
      }
      else
      {
        //-----------show first number of minute/ blink display
        AllOff();
        NumberON(14,k+2);
        delay(time_on);

        //-----------show second number of minute/ blink display
        AllOff();
        NumberON(15,j+2);
        delay(time_on);
        if (blink_latch &lt; 16) blink_latch++;
        else blink_latch = 0;
      }
     }

    //-----------------------------------------------------------------hour number show
    j = hour/10;
    k = hour%10;
    if(hour_blink==false)
    {
      //-----------show first number of hour
      AllOff();
      NumberON(16,k+2);
      delay(time_on);

      //-----------show second number of hour
      AllOff();
      NumberON(17,j+2);
      delay(time_on);
    }
    else
    {
      if(blink_latch &lt; 8) {  //blink_latch: time for blinking
        AllOff();
        delay(time_on);
        blink_latch++;
      }
      else
      {
        //-----------show first number of hour/ blink display
        AllOff();
        NumberON(16,k+2);
        delay(time_on);

        //-----------show second number of hour/ blink display
        AllOff();
        NumberON(17,j+2);
        delay(time_on);
        if (blink_latch &lt; 16) blink_latch++;
        else blink_latch = 0;
      }
    }

  //---------------------------------------mode choosen: push two button same time
  button_up_value = digitalRead(button_up); //normal ON (1)
  button_dn_value = digitalRead(button_dn); //normal ON (1)

  if((button_up_value==0)&amp;(button_dn_value==0)&amp;(mode_step==0)){
    mode_step = 1;
  }

  //---------------------------allow to change second
  if(mode_step==1){
    if (mode_counter &lt; 200){
      mode_counter++; // waiting time for changing value
    }
    else
    {
      mode_counter=0;
      mode_step=2;
      change_counter = 0;
    }
    sec_blink = true; // allow to change second
    min_blink = false;
    hour_blink = false;
  }

  //-------------------------allow to change minute
  if(mode_step==2){
    if (mode_counter &lt; 200){
      mode_counter++; // waiting time for changing value
    }
    else
    {
      mode_counter=0;
      mode_step=3;
      change_counter = 0;
    }

    sec_blink = false;
    min_blink = true; // allow to change minute
    hour_blink = false;
  }

  //-------------------------allow to change hour
  if(mode_step==3){
    if (mode_counter &lt; 200){
      mode_counter++; // waiting time for changing value
    }
    else 
    {
      mode_counter=0;
      mode_step=4;
      change_counter = 0;
    }

    sec_blink = false;
    min_blink = false;
    hour_blink = true;  // allow to change hour
  }

  //--------------------------escape changing time
  if(mode_step==4){
    mode_step=0;  // escape changing time
    sec_blink = false;
    min_blink = false;
    hour_blink = false;
    change_counter = 0;
  }

  //----------------------------------------------------------------------change-second +/-
  if ((button_up_value==0)&amp;(sec_blink==true)){
    second++;
    if (second&gt;59) second = 0;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setSecond(second);
      change_counter=0;
    }
  }

  if ((button_dn_value==0)&amp;(sec_blink==true)){
    second--;
    if (second&lt;0) second = 59;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setSecond(second);
      change_counter=0;
    }
  }

  //----------------------------------------------------------------------change-minute +/-

  if ((button_up_value==0)&amp;(min_blink==true)){
    minute++;
    if (minute&gt;59) minute = 0;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setMinute(minute);
      change_counter=0;
    }
  }

  if ((button_dn_value==0)&amp;(min_blink==true)){
    minute--;
    if (minute&lt;0) minute = 59;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setMinute(minute);
      change_counter=0;
    }
  }

  //----------------------------------------------------------------------change-hour +/-
  if ((button_up_value==0)&amp;(hour_blink==true)){
    hour++;
    if (hour&gt;23) hour = 0;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setHour(hour);
      change_counter=0;
    }
  }

  if ((button_dn_value==0)&amp;(hour_blink==true)){
    hour--;
    if (hour&lt;0) hour = 23;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setHour(hour);
      change_counter=0;
    }
  }
}

// --- Replacement for the on_number function
void NumberON(int Tube, int Digit){
  digitalWrite(NixieTubes, HIGH);
  digitalWrite(Digits, HIGH);
}

void AllOff(){
  // All Digits OFF
  for(int Counter; Counter&lt;=9; Counter++) {
    digitalWrite(Digits, LOW);
  }

  // All tubes OFF
  for(int Counter; Counter&lt;6; Counter++) {
    digitalWrite(NixieTubes, LOW);
  }
  
  delay(1);
}  

void NoPoison() {
 for(int Counter=0; Counter&lt;10; Counter++) {
   AllOff();

   // set all tubes to the same Number
   // wait half a second
   // switch all tubes off 
   // repeat for the next Number
   
   for(int Digit=0; Digit&lt;=9; Digit++) {
     for(int Tube=0; Tube&lt;6; Tube++) {
       NumberON(Tube, Digit); 
     }
     delay(5); // keep them on for 5 milliseconds
     AllOff();   // reset
   } 
  }
  
  delay(1);
}</pre>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3195</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3194</link>
                        <pubDate>Sun, 07 Mar 2021 15:12:11 +0000</pubDate>
                        <description><![CDATA[@hans hi hans im a bit confused about your last 3 recommendations , can you please gather them all in one code that you presume is the closer shot ? unfortunately im not as experienced as yo...]]></description>
                        <content:encoded><![CDATA[<p>@hans hi hans im a bit confused about your last 3 recommendations , can you please gather them all in one code that you presume is the closer shot ? unfortunately im not as experienced as you think i am and i have trouble for figuring it out by myself to where to add the codes you give me so if its possible either tell me where to add pieces of code you give me or give a solid text so i can compile without overthinking it to see if it works or not.<br />thanks</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>pejman1998</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3194</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3161</link>
                        <pubDate>Sun, 28 Feb 2021 16:04:00 +0000</pubDate>
                        <description><![CDATA[What I meant was this: have each Nixie, glow all the numbers at the same time (eg. 0,1,2,...,9 are for that one nixie ALL on at the same time).
I see what you mean though, the driver contro...]]></description>
                        <content:encoded><![CDATA[<p>What I meant was this: have each Nixie, glow all the numbers at the same time (eg. 0,1,2,...,9 are for that one nixie ALL on at the same time).</p>
<p>I see what you mean though, the driver controls only one nixie at a time, and only one segment in the nixie at a time.<br />In that case we'd have to modify the NoPoison again, I think ... just a quick thought:</p>
<p>1) The SetAll and AllOn function are not useful in this case, so remove those.</p>
<p>2) When trying to light up all nixies, we can probably use this?</p>
<p>I assume we can seat each Nixie to "0" by calling NumberOn for each tube.<br />Then turn them all OFF again, and repeat for "1", "2" etc.</p>
<p>Does this work?</p>
<pre contenteditable="false">void AllOff(){
  // All Digits OFF
  for(int Counter; Counter&lt;=9; Counter++) {
    digitalWrite(Digits, LOW);
  }

  // All tubes OFF
  for(int Counter; Counter&lt;6; Counter++) {
    digitalWrite(NixieTubes, LOW);
  }
  
  delay(1);
}  

void NoPoison() {
 for(int Counter=0; Counter&lt;10; Counter++) {
   AllOff();

   // set all tubes to the same Number
   // wait half a second
   // switch all tubes off 
   // repeat for the next Number
   
   for(int Digit=0; Digit&lt;=9; Digit++) {
     for(int Tube=0; Tube&lt;6; Tube++) {
       NumberON(Tube, Digit); 
     }
     delay(5); // keep them on for 5 milliseconds
     AllOff();   // reset
   } 
  }
  
  delay(1);
}</pre>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3161</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3159</link>
                        <pubDate>Sun, 28 Feb 2021 13:18:27 +0000</pubDate>
                        <description><![CDATA[@hans actually my clock works fine and all 6 of nixie tubes show the numbers at same time but the thing is its what my bare eyes (my brain) wants to believe , actually they turn on one by on...]]></description>
                        <content:encoded><![CDATA[<p>@hans actually my clock works fine and all 6 of nixie tubes show the numbers at same time but the thing is its what my bare eyes (my brain) wants to believe , actually they turn on one by one from right to left with a high frequency and because of POV to human eye it appears steady but with a camera it flickers  and the reason for multiplexing them is because the nixie driver ICs are rare and expensive so instead of having six ICs one for each tube i used one IC for all six of them ,this way my PSU shouldn't be very powerful since they turn off and on sequently , so what do you think were you aware of this before?should we change anything in your prior codes to make it work?</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>pejman1998</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3159</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3158</link>
                        <pubDate>Sun, 28 Feb 2021 11:15:41 +0000</pubDate>
                        <description><![CDATA[Hmm, that is not good ... I wonder why this is.Possibly my lack of knowledge on the Nixies ...?
Have you ever seen your Nixies all light up with all numbers on?Just wondering if your power-...]]></description>
                        <content:encoded><![CDATA[<p>Hmm, that is not good ... I wonder why this is.<br />Possibly my lack of knowledge on the Nixies ...?</p>
<p>Have you ever seen your Nixies all light up with all numbers on?<br />Just wondering if your power-supply is maybe not pulling it off?</p>
<p>If that is the case, then maybe this will work?<br />Instead of turning ALL digits on ALL tubes, at the same time, maybe mimic the Vegas protocol (= slot machines, where the wheels spin, all showing the same number).</p>
<p>I've changed the "delayMicroseconds" from the SetAll function, from 400 microseconds to 1 millisecond, and changed the NoPoison function to do this:</p>
<hr />
<p><strong><span style="color: #0000ff">Repeat 10 times:</span></strong></p>
<p><span style="color: #0000ff">  All Tubes OFF.</span></p>
<p><span style="color: #0000ff">  Repeat for each number (0-9): <br />    Set all tubes to a number, and leave it on that number for 5 milliseconds, and turn all tubes off again.</span><br /><span style="color: #0000ff"></span></p>
<p><span style="color: #0000ff">  When done with all 9 numbers, set all tubes OFF again.</span></p>
<hr />
<p> </p>
<p>Note that 1 millisecond = 1,000 microseconds, and 1 second = 1,000 milliseconds.<br />So I changed the delay from 400 microseconds to 1 millisecond (little more than double the time).</p>
<pre contenteditable="false">void SetAll(int NewState){
  // All tubes ON or OFF
  for(int Counter; Counter&lt;6; Counter++) {
    digitalWrite(NixieTubes, NewState);
  }
  // All Digits ON or OFF
  for(int Counter; Counter&lt;=9; Counter++) {
    digitalWrite(Digits, NewState);
  }
  
  delay(1);
}  

void NoPoison() {
 for(int Counter=0; Counter&lt;10; Counter++) {
   AllOff();

   // set all tubes to the same Number
   // wait half a second
   // switch all tubes off 
   // repeat for the next Number
   
   for(int Digit=0; Digit&lt;=9; Digit++) {
     for(int Tube=0; Tube&lt;6; Tube++) {
       NumberON(Tube, Digit);
     }
     delay(5); // keep them on for 5 milliseconds
     AllOff();   // reset
   } 
  }
  
  delay(1);
}</pre>
<p> </p>
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3158</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3157</link>
                        <pubDate>Sat, 27 Feb 2021 17:51:20 +0000</pubDate>
                        <description><![CDATA[@hans ok i just tested your new code and unfortunately the same thing happened with an exception that i could see that even though only 2 of tubes were glowing one of them was cycling the nu...]]></description>
                        <content:encoded><![CDATA[<p>@hans ok i just tested your new code and unfortunately the same thing happened with an exception that i could see that even though only 2 of tubes were glowing one of them was cycling the numbers over and over opposite of the prior code that after doing cycling it just returns to a normal clock mode until the next half hour , but  i thing you should have the hardware to tweak it yourself  then it would be fair to ask you for the code edition , i added the video of this times glitchy no poison cycle , thanks for your generosity to give your time to me<br /><a href="https://www.youtube.com/watch?v=L3cNSR5Thew&amp;ab_channel=BEHROOZKA" target="true">the 2nd video</a></p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>pejman1998</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3157</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3156</link>
                        <pubDate>Sat, 27 Feb 2021 17:16:15 +0000</pubDate>
                        <description><![CDATA[By what I&#039;m seeing in that other YouTube video, the digits are turned on/off very fast and several times?
So first thing, I think some of the code is a little confusing, in my own code as w...]]></description>
                        <content:encoded><![CDATA[<p>By what I'm seeing in that other YouTube video, the digits are turned on/off very fast and several times?</p>
<p>So first thing, I think some of the code is a little confusing, in my own code as well.<br />I understand you have 6 tubes (nixies) and each can have a the value 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9.</p>
<p>This doesn't quite add up with the wording and the idea of using arrays to talk to the tubes, and I did see a mistake in my own code as well.</p>
<p>I'd change your "nixie_X" variabel name to something like "Digit_X" or in an array:</p>
<pre contenteditable="false">int Digits[] = {2,3,4,5,6,7,8,9,10,11};</pre>
<p> </p>
<p>I'd change your "row_X" variable to "NixieTube_X" and if not to confusing, in an array as well:</p>
<pre contenteditable="false">int NixieTubes[] = {0,1,14,15,16,17};</pre>
<p> </p>
<p>Next thing I did was rewrite some of the original code.<br />Keep in mind that I do not have Nixie tubes available, so this is all untested ...</p>
<pre contenteditable="false">#include &lt;Wire.h&gt;
#include "DS3231.h"

RTClib RTC;
DS3231 Clock;

int hour;
int minute;
int second;

// arrays with the pins for the rubes and the digits
int Digits[] = {2,3,4,5,6,7,8,9,10,11};
int NixieTubes[] = {0,1,14,15,16,17};

const int button_up = 12;
const int button_dn = 13;

int button_up_value;
int button_dn_value;

boolean hour_blink, min_blink, sec_blink;
int blink_latch = 0;
int mode_step = 0;
int mode_counter = 0;
int change_counter = 0;

const int time_on = 2;  //time display each number of nixie tube

void setup() {
  for(int Counter=0; Counter&lt;=9; Counter++) {
    pinMode(NixieTubes, OUTPUT);
  }
  
  for(int Counter=0; Counter&lt;6; Counter++) {
    pinMode(Digits, OUTPUT);
  }

  pinMode(button_up, INPUT_PULLUP);
  pinMode(button_dn, INPUT_PULLUP);

  Wire.begin();

  hour_blink = false;
  min_blink = false;
  sec_blink = false;
}

void loop() {
    //-------------------get clock value---------------------------
    DateTime now = RTC.now();
    hour = now.hour();
    minute = now.minute();
    second = now.second();

    // --- Trigger NoPoison every half hour
    if( ( (minute==0) || (minute==30) ) &amp;&amp; (second==0) ) {
      NoPoison();
    }
      
    //-------------------show clock number ----------------------
    int j; //second number from right
    int k; //first number from right

    //-----------------------------------------------------------------------second number show
    j = second/10;
    k = second%10;

    if(sec_blink==false)
    {
      //-----------show first number of second
      AllOff();
      NumberON(0,k+2);
      delay(time_on);

      //-----------show second number of second
      AllOff();
      NumberON(1,j+2);
      delay(time_on);
    }
    else 
    {
      if(blink_latch &lt; 8){  //blink_latch: time for blinking
        AllOff();
        delay(time_on);
        blink_latch++;
      }
      else 
      {
        //-----------show first number of second/ blink display
        AllOff();
        NumberON(0,k+2);
        delay(time_on);

        //-----------show second number of second/ blink display
        AllOff();
        NumberON(1,j+2);
        delay(time_on);
        if (blink_latch &lt; 16) blink_latch++;
        else blink_latch = 0;
      }
    }

    //-------------------------------------------------------------minute number show
    j = minute/10;
    k = minute%10;

    if(min_blink==false)
    {
      //-----------show first number of minute
      AllOff();
      NumberON(14,k+2);
      delay(time_on);
      //-----------show second number of minute
      AllOff();
      NumberON(15,j+2);
      delay(time_on);
    }
    else
    {
      if(blink_latch &lt; 8){  //blink_latch: time for blinking
        AllOff();
        delay(time_on);
        blink_latch++;
      }
      else
      {
        //-----------show first number of minute/ blink display
        AllOff();
        NumberON(14,k+2);
        delay(time_on);

        //-----------show second number of minute/ blink display
        AllOff();
        NumberON(15,j+2);
        delay(time_on);
        if (blink_latch &lt; 16) blink_latch++;
        else blink_latch = 0;
      }
     }

    //-----------------------------------------------------------------hour number show
    j = hour/10;
    k = hour%10;
    if(hour_blink==false)
    {
      //-----------show first number of hour
      AllOff();
      NumberON(16,k+2);
      delay(time_on);

      //-----------show second number of hour
      AllOff();
      NumberON(17,j+2);
      delay(time_on);
    }
    else
    {
      if(blink_latch &lt; 8) {  //blink_latch: time for blinking
        AllOff();
        delay(time_on);
        blink_latch++;
      }
      else
      {
        //-----------show first number of hour/ blink display
        AllOff();
        NumberON(16,k+2);
        delay(time_on);

        //-----------show second number of hour/ blink display
        AllOff();
        NumberON(17,j+2);
        delay(time_on);
        if (blink_latch &lt; 16) blink_latch++;
        else blink_latch = 0;
      }
    }

  //---------------------------------------mode choosen: push two button same time
  button_up_value = digitalRead(button_up); //normal ON (1)
  button_dn_value = digitalRead(button_dn); //normal ON (1)

  if((button_up_value==0)&amp;(button_dn_value==0)&amp;(mode_step==0)){
    mode_step = 1;
  }

  //---------------------------allow to change second
  if(mode_step==1){
    if (mode_counter &lt; 200){
      mode_counter++; // waiting time for changing value
    }
    else
    {
      mode_counter=0;
      mode_step=2;
      change_counter = 0;
    }
    sec_blink = true; // allow to change second
    min_blink = false;
    hour_blink = false;
  }

  //-------------------------allow to change minute
  if(mode_step==2){
    if (mode_counter &lt; 200){
      mode_counter++; // waiting time for changing value
    }
    else
    {
      mode_counter=0;
      mode_step=3;
      change_counter = 0;
    }

    sec_blink = false;
    min_blink = true; // allow to change minute
    hour_blink = false;
  }

  //-------------------------allow to change hour
  if(mode_step==3){
    if (mode_counter &lt; 200){
      mode_counter++; // waiting time for changing value
    }
    else 
    {
      mode_counter=0;
      mode_step=4;
      change_counter = 0;
    }

    sec_blink = false;
    min_blink = false;
    hour_blink = true;  // allow to change hour
  }

  //--------------------------escape changing time
  if(mode_step==4){
    mode_step=0;  // escape changing time
    sec_blink = false;
    min_blink = false;
    hour_blink = false;
    change_counter = 0;
  }

  //----------------------------------------------------------------------change-second +/-
  if ((button_up_value==0)&amp;(sec_blink==true)){
    second++;
    if (second&gt;59) second = 0;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setSecond(second);
      change_counter=0;
    }
  }

  if ((button_dn_value==0)&amp;(sec_blink==true)){
    second--;
    if (second&lt;0) second = 59;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setSecond(second);
      change_counter=0;
    }
  }

  //----------------------------------------------------------------------change-minute +/-

  if ((button_up_value==0)&amp;(min_blink==true)){
    minute++;
    if (minute&gt;59) minute = 0;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setMinute(minute);
      change_counter=0;
    }
  }

  if ((button_dn_value==0)&amp;(min_blink==true)){
    minute--;
    if (minute&lt;0) minute = 59;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setMinute(minute);
      change_counter=0;
    }
  }

  //----------------------------------------------------------------------change-hour +/-
  if ((button_up_value==0)&amp;(hour_blink==true)){
    hour++;
    if (hour&gt;23) hour = 0;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setHour(hour);
      change_counter=0;
    }
  }

  if ((button_dn_value==0)&amp;(hour_blink==true)){
    hour--;
    if (hour&lt;0) hour = 23;
    change_counter++; //prevent value change too fast
    mode_counter = 0; //hold mode
    if(change_counter&gt;5){
      Clock.setHour(hour);
      change_counter=0;
    }
  }
}

// --- Replacement for the on_number function
void NumberON(int Tube, int Digit){
  digitalWrite(NixieTubes, HIGH);
  digitalWrite(Digits, HIGH);
}

// --- Sets all tubes and digits to LOW
void AllOff() {
  SetAll(LOW); // LOW = OFF
}

// --- Sets all tubes and digits to HIGH
void AllOn() {
  SetAll(HIGH); // HIGH = ON
}

// --- Sets all tubes and digits to either LOW or HIGH (used by AllOn and AllOff)
void SetAll(int NewState){
  // All tubes ON or OFF
  for(int Counter; Counter&lt;6; Counter++) {
    digitalWrite(NixieTubes, NewState);
  }
  // All Digits ON or OFF
  for(int Counter; Counter&lt;=9; Counter++) {
    digitalWrite(Digits, NewState);
  }
  
  delayMicroseconds(400);  //to prevent "ghost" effect to other tube
}  
    
// --- Toggle all Tubes and Numbers ON and OFF 10 times
// --- You can change "10" to a different number if that works better 
void NoPoison() {
 for(int Counter=0; Counter&lt;10; Counter++) {
   AllOn();
   AllOff();
  }
}</pre>
<p> </p>
<p>At the end you'll see that I've removed and replaced the old <strong>on_number</strong> and <strong>off_all</strong> functions.<br />I've added also <strong>AllOn</strong> and <strong>SetAll</strong>.</p>
<p>For ON and OFF switching for all tubes and digits we'd  need the same loops, just a different value.<br />This is where SetAll comes in play, as you can pass it the value (LOW or HIGH) we'd like to use.<br />This function is used by AllOn and AllOff.</p>
<p>You now see that we can write the NoPoison function a lot shorter as well.</p>
<p>Note: I've also added the 30 minute check (at the beginning of the void loop).</p>
<p>In the NoPoison function, up to you to determine if 10 is a good value 😊 </p>
<p> </p>
<p>I hope this helps (and works hahah - it does compile, I just cannot test it by lack of hardware)!</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3156</guid>
                    </item>
				                    <item>
                        <title>RE: Nixie Clock - How can i add my desired function to this code</title>
                        <link>https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3155</link>
                        <pubDate>Sat, 27 Feb 2021 15:39:08 +0000</pubDate>
                        <description><![CDATA[@hans yes you are right its been a while loli meant that even though it starts to work at the time of 30 or 00 minutes (which turns on only 2 tubes ) it starts to glow the digits sequently w...]]></description>
                        <content:encoded><![CDATA[<p>@hans yes you are right its been a while lol<br />i meant that even though it starts to work at the time of 30 or 00 minutes (which turns on only 2 tubes ) it starts to glow the digits sequently while the earlier digits glow new ones starts to glow i've uploaded the video for you to see <a href="https://www.youtube.com/watch?v=bR6WwKotNXQ&amp;ab_channel=BEHROOZKA" target="true">this is my video with our code</a></p>
<p>you see that when it starts to change the time to new hour it kinda works but what we intened to make is something like this in <a href="https://www.youtube.com/watch?v=skBwGGQ58MI&amp;ab_channel=Spirit" target="true">  this video made by some you-tuber</a> so i will test your new suggestion and i will tell you if it worked or not <br />thanks a lot </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>pejman1998</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/how-can-i-add-my-desired-function-to-this-code/#post-3155</guid>
                    </item>
							        </channel>
        </rss>
		