// Simulates 6 Nixie TUBES.
// The Nixie tube and driver (K155ID1 or 74141) are
// simulated by a custom chip and 7 segment display.
// NOTE: This wiring diagram omits the current limiting resistor that actual nixies require !
#define DATA_PIN 8 // Pin connected to DS of 74HC595
#define LATCH_PIN 9 // Pin connected to STCP of 74HC595
#define CLOCK_PIN 10 // Pin connected to SHCP of 74HC595
#define NIXIES 6 // The number of nixie tubes
#define HALF_NIXIES NIXIES / 2 // Half the number of nixie tubes
#define EMPTY 11 // Value to assign to nixie to display nothing
byte nixie[NIXIES] = { 0, 0, 0, 0, 0, 0};
byte shiftRegisterData[HALF_NIXIES] = { 0, 0, 0};
int counter = 0;
void setup() {
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
Serial.begin(115200);
}
void loop() {
SpinBounce();
DebugLog();
OutputNixies();
counter++;
delay(20);
}
void SpinBounce()
{
for(int i=0; i<NIXIES; i++)
{
float f = (float)counter / 15.0;
float sineIndex = sin(f) * HALF_NIXIES + HALF_NIXIES;
int number = (counter/8) % 10;
nixie[i] = floor(sineIndex) == i ? number : EMPTY;
}
}
void OutputNixies() {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, (nixie[4] << 4) | nixie[5]);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, (nixie[2] << 4) | nixie[3]);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, (nixie[0] << 4) | nixie[1]);
digitalWrite(LATCH_PIN, HIGH);
}
void DebugLog()
{
String out = "";
for(int i=0; i<NIXIES; i++)
{
if (nixie[i] == EMPTY)
out += " ";
else
out += String(nixie[i]);
}
Serial.println(out);
}