engineer2you
Published © GPL3+

Nixie Clock with Arduino | Simplest Design

Making Nixie clock with Arduino UNO and opto-isolation chip only.

IntermediateFull instructions provided3 hours24,712
Nixie Clock with Arduino | Simplest Design

Things used in this project

Story

Read more

Code

Code snippet #1

Plain text
//Youtube channel: engineer2you
#include <Wire.h>
#include "DS3231.h"

RTClib RTC;
DS3231 Clock;

int hour;
int minute;
int second;

const int nixie_0 = 2;
const int nixie_1 = 3;
const int nixie_2 = 4;
const int nixie_3 = 5;  
const int nixie_4 = 6;
const int nixie_5 = 7;
const int nixie_6 = 8;
const int nixie_7 = 9;
const int nixie_8 = 10;
const int nixie_9 = 11;

const int row_1 = 0;
const int row_2 = 1;
const int row_3 = 14;
const int row_4 = 15;
const int row_5 = 16;
const int row_6 = 17;

const int time_on = 2;

void setup() {
  pinMode(nixie_0, OUTPUT);
  pinMode(nixie_1, OUTPUT);
  pinMode(nixie_2, OUTPUT);
  pinMode(nixie_3, OUTPUT);
  pinMode(nixie_4, OUTPUT);
  pinMode(nixie_5, OUTPUT);
  pinMode(nixie_6, OUTPUT);
  pinMode(nixie_7, OUTPUT);
  pinMode(nixie_8, OUTPUT);
  pinMode(nixie_9, OUTPUT);
  pinMode(row_1, OUTPUT);
  pinMode(row_2, OUTPUT);
  pinMode(row_3, OUTPUT);
  pinMode(row_4, OUTPUT);
  pinMode(row_5, OUTPUT);
  pinMode(row_6, OUTPUT);
  //Serial.begin(9600); //should NOT use seiral println, it will effect to output pin D0 & D1
  Wire.begin();
}

void loop() {
    //-------------------get clock value---------------------------
    DateTime now = RTC.now();
    hour = now.hour();
    minute = now.minute();
    second = now.second();

    //-------------------show clock number ----------------------
    int j; //second number from right
    int k; //first number from right

      j = second/10;
      k = second%10;
      //-----------show first number of second
      off_all();
      on_number(0,k+2);
      delay(time_on);
      //-----------show second number of second
      off_all();
      on_number(1,j+2);
      delay(time_on);
      
      j = minute/10;
      k = minute%10;
      //-----------show first number of minute
      off_all();
      on_number(14,k+2); 
      delay(time_on);
      //-----------show second number of minute
      off_all();
      on_number(15,j+2);
      delay(time_on);

      j = hour/10;
      k = hour%10;
      //-----------show first number of hour
      off_all();
      on_number(16,k+2); 
      delay(time_on);
      //-----------show second number of hour
      off_all();
      on_number(17,j+2);
      delay(time_on);
}

void on_number(int row, int nixie){
  digitalWrite(row, HIGH);
  digitalWrite(nixie, HIGH);
}

void off_all(){
  digitalWrite(row_1, LOW);
  digitalWrite(row_2, LOW);
  digitalWrite(row_3, LOW);
  digitalWrite(row_4, LOW);
  digitalWrite(row_5, LOW);
  digitalWrite(row_6, LOW);
  digitalWrite(nixie_0, LOW);
  digitalWrite(nixie_1, LOW);
  digitalWrite(nixie_2, LOW);
  digitalWrite(nixie_3, LOW);
  digitalWrite(nixie_4, LOW);
  digitalWrite(nixie_5, LOW);
  digitalWrite(nixie_6, LOW);
  digitalWrite(nixie_7, LOW);
  digitalWrite(nixie_8, LOW);
  digitalWrite(nixie_9, LOW);

  delayMicroseconds(400);  //to prevent "ghost" effect to other tube
}

Credits

engineer2you

engineer2you

24 projects • 93 followers
i'm mechatronics engineer who loves making funny project and sharing for you. See me at: https://www.youtube.com/c/engineer2you

Comments