How to turn off a nixie tube in the code

I am trying to make a single tube Nixie clock using a DS3231

The clock works fine but I need help to turn off the digets as it cycles/flashes through the time.

It is particularly a problem when there double numbers for example 11:11 in my code just shows the 1 continuously, what I would like it to do is blink the 1 four times followed by a longer pause.

This is my code

float HOURS = 00;
float MINS = 00;

#include <DS3231_Simple.h> // Attached to I2C
DS3231_Simple Clock;


byte A = 10; //pins for the inputs on the Russian version of SN74141
byte B = 11;
byte C = 12;
byte D = 13;


void setup() {

  Clock.begin();

  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
  nixieWrite(A, B, C, D, 0);
}

void nixieWrite(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t value) {
  //D is most significant bit
  //A is least significant bit
  digitalWrite(d, (value & 0x08) >> 3);
  digitalWrite(c, (value & 0x04) >> 2);
  digitalWrite(b, (value & 0x02) >> 1);
  digitalWrite(a, value & 0x01);
}

void loop() {


  // Create a variable to hold the data
  DateTime MyDateAndTime;

  // Ask the clock for the data.
  MyDateAndTime = Clock.read();

  HOURS = (MyDateAndTime.Hour);
  MINS = (MyDateAndTime.Minute);

  //////////FOR A TIME HOURS = 12 and MINUTES = 34

  float TV1 = HOURS / 10; //   12 / 10 = 1.2
  int FDiget = TV1; // First Diget.... Remove decimal = 1
  int TV2 = FDiget * 10; // 1*10=10

 
 int SDiget = HOURS - TV2; //Second Diget  12-10=2

 
  float TV4 = MINS / 10; //  34/4=3.4
  int TDiget = TV4;  // Third Diget  remove decimal = 3
  int TV5 = TDiget * 10; // 3 * 10 = 30

  int LastDiget = MINS - TV5; // Last Diget 34 -30 = 4

  nixieWrite(A, B, C, D, FDiget);
  
  delay (500) ;

  nixieWrite(A, B, C, D, SDiget);
  
  delay (500) ;

  nixieWrite(A, B, C, D, TDiget);
  
  delay (500) ;

  nixieWrite(A, B, C, D, LastDiget);
  
  delay (1500);


}

Any help would be appreciated :slight_smile:

After each digit has been displayed for its time (.5s) blank the Nixie for x milliseconds. After the last digit blank the display for a longer y milliseconds

What nixie tube? What driver circuit?

You function nixieWrite() doesn't appear to be able to distinguish blank from zero. What does it display if you give it the value zero?

It looks like the values 0 through 9 will light the ten digits. What do the remaining 4-bit values (10-15) do? I suspect at least one of them selects "no digit". Try them out.

  nixieWrite(A, B, C, D, FDiget);

  delay (450) ;

  nixieWrite(A, B, C, D, NO_DIGIT);

  delay (50) ;

  nixieWrite(A, B, C, D, SDiget);

If you are using a 74141 driver it looks like any value over 9 will turn off all digits.

The tube is a IN-12A, I have a Nano connected to a K155N driver and the anode on the tube connected to a High voltage supply, all grounds are connected.

I have tried writing 10 and 11 and that messed with things producing random output across the board.

I will try the others, thank you for the suggestion.

kenl: I will try the others, thank you for the suggestion.

Look up a datasheet for the 74141 type. You should find a truth table listing what outputs are active for a given set of inputs.

The Russian "К155ИД1" (K155ID1) chip doesn't seem to have a defined way to turn off all of the outputs. One of the input patterns MAY do it. I would try values 10 through 15 in the hopes that one of those patterns happens to turn off all of the outputs

Or you could switch to the 74141.

Or maybe you can have an LED to punctuate the intervals between digits?

I have it working now, I am writing a 10 to the K1551 and it working as wanted, the only thing I am doing differently today is I created a variable for the No Digit rather than just typing in the 10. I’m not sure why that made a difference?

int NDiget = 10; // create variable for no display

nixieWrite(A, B, C, D, NDiget); //works

nixieWrite(A, B, C, D, 10); //Doesn’t work?

float HOURS = 00;
float MINS = 00;

#include <DS3231_Simple.h> // Attached to I2C
DS3231_Simple Clock;


byte A = 10; //pins for the inputs on the Russian version of SN74141
byte B = 11;
byte C = 12;
byte D = 13;


void setup() {

  

  Clock.begin();

  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
  nixieWrite(A, B, C, D, 0);
}

void nixieWrite(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t value) {
  //D is most significant bit
  //A is least significant bit
  digitalWrite(d, (value & 0x08) >> 3);
  digitalWrite(c, (value & 0x04) >> 2);
  digitalWrite(b, (value & 0x02) >> 1);
  digitalWrite(a, value & 0x01);
}

void loop() {

int NDiget = 10; // create variable for no display
 
  
  // Create a variable to hold the data
  DateTime MyDateAndTime;

  // Ask the clock for the data.
  MyDateAndTime = Clock.read();

  HOURS = (MyDateAndTime.Hour);
  MINS = (MyDateAndTime.Minute);

  //////////FOR A TIME HOURS = 12 and MINUTES = 34

  float TV1 = HOURS / 10; //   12 / 10 = 1.2
  int FDiget = TV1; // First Diget.... Remove decimal = 1
  int TV2 = FDiget * 10; // 1*10=10


  int SDiget = HOURS - TV2; //Second Diget  12-10=2


  float TV4 = MINS / 10; //  34/4=3.4
  int TDiget = TV4;  // Third Diget  remove decimal = 3
  int TV5 = TDiget * 10; // 3 * 10 = 30

  int LastDiget = MINS - TV5; // Last Diget 34 -30 = 4


if (FDiget > 0){
  nixieWrite(A, B, C, D, FDiget);
  delay (500) ;
 nixieWrite(A, B, C, D, NDiget);
 delay (100) ;
}
 
 else{
  nixieWrite(A, B, C, D, SDiget);
  delay (500) ;
  nixieWrite(A, B, C, D, NDiget);
 delay (150) ;
 }

  nixieWrite(A, B, C, D, TDiget);
  delay (500) ;
 nixieWrite(A, B, C, D, NDiget);
 delay (100) ;

  nixieWrite(A, B, C, D, LastDiget);
  delay (500);
  nixieWrite(A, B, C, D, NDiget);
 delay (1000) ;
 
}

Thank you for the help! :slight_smile:

  if (FDiget > 0)
  {
    nixieWrite(A, B, C, D, FDiget);
    delay (500) ;
    nixieWrite(A, B, C, D, NDiget);
    delay (100) ;
  }
  else
  {
    nixieWrite(A, B, C, D, SDiget);
    delay (500) ;
    nixieWrite(A, B, C, D, NDiget);
    delay (150) ;
  }

Are you sure you don't want to display the second hours digit unless the first hours digit is zero? That would count: 1,2,3,4,5,6,7,8,9,1,1,1,1,2,3,4,l5,6,7... It wouldn't show only 1 for 10, 11, and 12.

Yes I picked that up too, now fixed :)

Like all my code it's very basic and constantly evolving, sometimes not for the best :(