// Simulates a 6 digit Nixie Clock.
// The Nixie tube and driver (K155ID1 or 74141) are
// simulated by a custom chip and 7 segment display.
#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 LED_PIN 7 // Led Data Pin
#define NUM_LEDS 6 // The number of leds
byte data[3] = { 0, 0, 0}; // hh, mm, ss
byte nixie[6] = { 0, 0, 0, 0, 0, 0};
int counter = 0;
void setup() {
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
Serial.begin(115200);
randomSeed(analogRead(0));
}
void loop() {
for(int i=0; i<6; i++)
{
float f = (float)i / 6.0;
nixie[i] = sin(f * PI) * 9;
}
// nixie[0] = 1;
// nixie[1] = 2;
// nixie[2] = 3;
// nixie[3] = 4;
// nixie[4] = 5;
// nixie[5] = 6;
outputNixies();
counter++;
delay(200);
}
void outputNixies() {
data[0] = setByte(nixie[0], nixie[1]);
data[1] = setByte(nixie[2], nixie[3]);
data[2] = setByte(nixie[4], nixie[5]);
shiftOutData();
}
void shiftOutData() {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, data[2]);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, data[1]);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, data[0]);
digitalWrite(LATCH_PIN, HIGH);
}Minutes
Hours
Seconds