To run my Nixie tubes I am using the K155ID1 data chip, along with the DS1307 RTC that is controlled by a Arduino Mega.
I can run a test code that will cycle through 1-9 and my nixie tubes will display all of the correct numbers.
#include <Wire.h>
#define RTC 0x68
#define Hours 0x23
#define Minutes 0x59
#define Seconds 0x45
#define Day 0x5
#define Date 0x31
#define Month 0x12
#define Year 0x99
//hours
#define A1 23
#define B1 25
#define C1 27
#define D1 29
//hours
#define A2 31
#define B2 33
#define C2 35
#define D2 37
//minutes second part
#define A3 39
#define B3 41
#define C3 43
#define D3 45
//minute first part
#define A4 22
#define B4 24
#define C4 26
#define D4 28
//seconds
#define A5 30
#define B5 32
#define C5 34
#define D5 36
//seconds
#define A6 38
#define B6 40
#define C6 42
#define D6 44
char *LINE2Day[8] = {" Not A Day", "Sunday ", "Monday ", "Tuesday ", "Wednesday", "Thursday", "Friday ", "Saturday"};
int ClockArray[8];
int OldClockArray[8];
char A[6] = {A1, A2, A3, A4, A5, A6};
char B[6] = {B1, B2, B3, B4, B5, B6};
char C[6] = {C1, C2, C3, C4, C5, C6};
char D[6] = {D1, D2, D3, D4, D5, D6};
//Golbal
byte iHours = 0;
byte iMinutes = 0;
byte iSeconds = 0;
byte iDay = 0;
byte iDate = 0;
byte iMonth = 0;
byte iYear = 0;
byte zero = 0;
byte one = 0;
byte two = 0;
byte three = 0;
byte four = 0;
byte five = 0;
void setup()
{
pinMode(A1, OUTPUT);
pinMode(B1, OUTPUT);
pinMode(C1, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(B2, OUTPUT);
pinMode(C2, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(B3, OUTPUT);
pinMode(C3, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(B4, OUTPUT);
pinMode(C4, OUTPUT);
pinMode(D4, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(B5, OUTPUT);
pinMode(C5, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(A6, OUTPUT);
pinMode(B6, OUTPUT);
pinMode(C6, OUTPUT);
pinMode(D6, OUTPUT);
for (char i = 0; i < 6; i++) {
digitalWrite(A[i], HIGH);
digitalWrite(B[i], HIGH);
digitalWrite(C[i], HIGH);
digitalWrite(D[i], HIGH);
}
// if (!RTC.isRunning())
// RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
//I2C setup
Wire.begin();
void writenumber(int a, int b)
{
switch (b) {
case 0:
digitalWrite(A[a], LOW);
digitalWrite(B[a], LOW);
digitalWrite(C[a], LOW);
digitalWrite(D[a], LOW);
break;
case 9:
digitalWrite(A[a], HIGH);
digitalWrite(B[a], LOW);
digitalWrite(C[a], LOW);
digitalWrite(D[a], LOW);
break;
case 8:
digitalWrite(A[a], LOW);
digitalWrite(B[a], HIGH);
digitalWrite(C[a], LOW);
digitalWrite(D[a], LOW);
break;
case 7:
digitalWrite(A[a], HIGH);
digitalWrite(B[a], HIGH);
digitalWrite(C[a], LOW);
digitalWrite(D[a], LOW);
break;
case 6:
digitalWrite(A[a], LOW);
digitalWrite(B[a], LOW);
digitalWrite(C[a], HIGH);
digitalWrite(D[a], LOW);
break;
case 5:
digitalWrite(A[a], HIGH);
digitalWrite(B[a], LOW);
digitalWrite(C[a], HIGH);
digitalWrite(D[a], LOW);
break;
case 4:
digitalWrite(A[a], LOW);
digitalWrite(B[a], HIGH);
digitalWrite(C[a], HIGH);
digitalWrite(D[a], LOW);
break;
case 3:
digitalWrite(A[a], HIGH);
digitalWrite(B[a], HIGH);
digitalWrite(C[a], HIGH);
digitalWrite(D[a], LOW);
break;
case 2:
digitalWrite(A[a], LOW);
digitalWrite(B[a], LOW);
digitalWrite(C[a], LOW);
digitalWrite(D[a], HIGH);
break;
case 1:
digitalWrite(A[a], HIGH);
digitalWrite(B[a], LOW);
digitalWrite(C[a], LOW);
digitalWrite(D[a], HIGH);
break;
}
}
void off(int a) {
digitalWrite(A[a], HIGH);
digitalWrite(B[a], HIGH);
digitalWrite(C[a], HIGH);
digitalWrite(D[a], HIGH);
}
// LCD Software Initialization
_lcdinit(); // Call _lcdinit() function (User difine function)
void RTC_int()
{
Wire.beginTransmission(RTC); //opens commucation with RTC
Wire.write(0x00); //Set RTC address to be accessed can only set one byte at a time
Wire.write(Seconds);
Wire.write(Minutes);
Wire.write(Hours);
Wire.write(Day);
Wire.write(Date);
Wire.write(Month);
Wire.write(Year);
//DS1307 output frequency for 8.192 Khz
Wire.write(0x12);
Wire.endTransmission();
}
void _lcdinit()
{
for (int i = 0; i < 10; i++) {
for (int m = 0; m < 6; m++) {
writenumber(m, i);
}
delay(500);
}
}
void RTC_read()
{
OldClockArray[0] = iMonth; // Old Array postion for the sotred value for the Month
OldClockArray[1] = iDate; // Old Array postion for the sotred value for the Date
OldClockArray[2] = iYear; // Old Array postion for the sotred value for the Year
OldClockArray[3] = iHours; // Old Array postion for the sotred value for the hour
OldClockArray[4] = iMinutes; // Old Array postion for the sotred value for the Minute
OldClockArray[5] = iSeconds; // Old Array postion for the sotred value for the Second
OldClockArray[6] = iDay; // Old Array postion for the sotred value for the Day
Wire.beginTransmission(RTC); //opens commucation with RTC
Wire.write(0x00); // this tells the program where to start reading from
Wire.endTransmission(); // Close I2C commucation with RTC
// need to request the other bite from the RTCby requestion 3 bytes(you can add more if needed)
Wire.requestFrom(RTC, 7); // You want it to read everything except the square wave
iSeconds = Wire.read() & 0x7f; //Store Seconds
iMinutes = Wire.read() & 0x7f; //Store minutes
iHours = Wire.read() & 0x3f; //Store Hours
iDay = Wire.read() & 0x07; //Store days
iDate = Wire.read() & 0x3f; //Store date
iMonth = Wire.read() & 0x1f; //Store Month
iYear = Wire.read() & 0xff; //Store year
ClockArray[0] = iMonth; // Array postion for the sotred value for the Month
ClockArray[1] = iDate; // Array postion for the sotred value for the Date
ClockArray[2] = iYear; // Array postion for the sotred value for the Year
ClockArray[3] = iHours; // Array postion for the sotred value for the hour
ClockArray[4] = iMinutes; // Array postion for the sotred value for the Minute
ClockArray[5] = iSeconds; // Array postion for the sotred value for the Second
ClockArray[6] = iDay; // Array postion for the sotred value for the Day
}
void Console_Read()
{
if ((ClockArray[5] & 0x0F) == 0x00)
{
if (ClockArray[5] != OldClockArray[5])
{
for (int i = 0; i < 6; i++)
{
if (ClockArray[i] < 10)
{
Serial.print('0'); // padding for the 0
}
Serial.print(ClockArray[i]);
}
Serial.print('\n');
}
}
}
void loop()
{
/**************************************** The main run loop **********************************
Notes:
runs through a data packet that containing the configuration setting reqired for the 8 programmed registers of
the DS1307 RTC used in this programm. That will use the RTC to count the time.
******************************************************************************************/
RTC_read();
Console_Read();
Nixie_Tube();
// zero = (iHours / 10) % 10;
// one = iHours % 10;
// two = (iMinute / 10) % 10;
// three = iMinute % 10;
// four = (iSeconds / 10) % 10;
// five = iSeconds % 10;
// Serial.println(zero);
// Serial.println(one);
// Serial.println(two);
// Serial.println(three);
//delay(1000);
}
[code]
Nixie_ schematic.pdf (404 KB)