Video tutorial
Arduino "One Digit" IV9 Numitron Clock

Arduino "One Digit" IV9 Numitron Clock © GPL3+

Another one of the series of unusual clocks I made.

  • 3,487 views
  • 17 comments
  • 9 respects

Components and supplies

IV9 numitron tube
×1
Ard nano
Arduino Nano R3
×1

Necessary tools and machines

09507 01
Soldering iron (generic)

About this project

Another one of the series of unusual clocks I made on the basis of the website: http://blog.thelifeofkenneth.com/2009..., where you can find a sketch for this project.

Schematic at the end of the video.

Thanks for watching!

Code

codeArduino
// 2009 Kenneth Finnegan
// kennethfinnegan.blogspot.com

#include <Wire.h>

// I2C address
#define DS1307 B1101000

// pinout for the 7 segment display
// Starts top center, clock-wise, then
// center line, then dot
byte segment[] = {
  3, 2, 5, 6, 7, 8, 9, 4};

byte second=0, minute=0, hour=0;

void updatetime();
void printtime();
void print7digit(byte number);
byte DECTOBCD(byte val);
byte BCDTODEC(byte val);

void setup() {
  byte i;
  Wire.begin();

  for (i=0; i<8; i++) {
    pinMode(segment[i], OUTPUT);
    digitalWrite(segment[i], LOW);
  }
}

void loop() {
  updatetime();
  printtime();
}

// Pull current time off the DS1307
void updatetime() {
  Wire.beginTransmission(DS1307);
  Wire.write(0x00);
  Wire.endTransmission();
  Wire.requestFrom(DS1307, 3);
  // Don't actually use seconds value. Feel free to.
  second = BCDTODEC(Wire.read() & 0x7f);
  minute = BCDTODEC(Wire.read());
  hour   = BCDTODEC(Wire.read() & 0x3f); 
}

// Flash each digit of the time in turn on the 7 segment
void printtime() {
  byte j;
  // Convert from 24 hour to 12 hour mode
  // Should be done on the DS1307. I'm sorry.
  byte temphour = hour % 12;
  if (temphour == 0) {
    // Not zero based, not one based, but 12 based.
    temphour = 12;
  }
  
  // Only display highest digit if it's nonzero
  if (temphour > 9) {
    print7digit(temphour/10);
    delay(500); // Repeated magic values in my code? Never!
    for (j=0; j<8; j++) {
      digitalWrite(segment[j], LOW);
    }
    delay(150);
  }
  print7digit(temphour % 10);
  // Light the dot on last hour digit
  digitalWrite(segment[7], HIGH);
  delay(500);
  for (j=0; j<8; j++) {
    digitalWrite(segment[j], LOW);
  }
  delay(500);
  
  print7digit(minute/10);
  delay(500);
  for (j=0; j<8; j++) {
    digitalWrite(segment[j], LOW);
  }
  delay(150);
  print7digit(minute%10);
  delay(500);
  for (j=0; j<8; j++) {
    digitalWrite(segment[j], LOW);
  }
  delay(2000);
}

// Display a single digit on the 7 segment
void print7digit(byte number) {
  // Bitfield for digits 0-9
  const byte numtable[] = {
    B00111111,
    B00000110,
    B01011011,
    B01001111,
    B01100110,
    B01101101,
    B01111101,
    B00000111,
    B01111111,
    B01100111  };
  byte litpins = numtable[number];
  byte i;
  for (i=0; i<8; i++) {
    digitalWrite(segment[i], (litpins>>i) & 1);
  }
} 

byte DECTOBCD(byte val) {
  return ((val/10)<<4) + (val%10);
}
byte BCDTODEC(byte val) {
  return (val>>4) * 10 + (val & 0xf);
}

Schematics

IV9 Numitron clock
Shematic vvwjjwx6oe

Comments

Similar projects you might like

Arduino Clock with Neopixel Ring Animation

Project tutorial by Alexander

  • 42,145 views
  • 39 comments
  • 64 respects

RTC Based Clock

Project tutorial by shivakumarj1995

  • 9,522 views
  • 13 comments
  • 12 respects

Cheap NeoPixel Strip Clock

Project in progress by JaeKar99

  • 3,208 views
  • 4 comments
  • 9 respects

Android Things Word Clock

Project tutorial by Daniele Bonaldo

  • 18,067 views
  • 7 comments
  • 103 respects

Clock Arduino Nano NeoPixel Ring Alarm/Timer Function

Project in progress by WannaDuino

  • 9,412 views
  • 18 comments
  • 38 respects

Animated RGB Wall Clock

Project tutorial by TheTNR

  • 9,123 views
  • 6 comments
  • 36 respects
Add projectSign up / Login