Dishy
Published © CC BY-NC

The "НЦИЧ" Nixie Watch

The "Hopefully I don't abandon it mid-way" Nixie Watch. Fully Open-source, 3D printed, Cheap and Easily replicated! -WIP-

AdvancedWork in progress10 hours1,218
The "НЦИЧ" Nixie Watch

Things used in this project

Hardware components

ATtiny841
Microchip ATtiny841
×1

Story

Read more

Schematics

Basic Schematic for Nixie Watch

Code

Nixie Watch Rev 4 Sketch 1

Arduino
It's a simple code trying to see if it would actually work, not optimized and still programming.
/*
  ShiftRegister74HC595 - Library for simplified control of 74HC595 shift registers.
  Created by Timo Denk (www.timodenk.com), Nov 2014.
  Additional information is available at http://shiftregister.simsso.de/
  Released into the public domain.
*/

#include <ShiftRegister74HC595.h>
#include "uRTCLib.h"

uRTCLib rtc(0x68, 0x57);

volatile int isr_flag = 0;
/*
   OK: Workflow for tech Demo:
   EN Set H
   LE LOW, BL H, POL H
   BL - 7
   DIN - 1
   LE - 0
   CLK - 10
   POL - 9
   EN - 8
*/

#define BL 7
#define DIN 1
#define LE 0
#define CLK 10
#define POL 9
#define EN 8
ShiftRegister74HC595<4> sr (DIN, CLK, LE);
const int BTN1 = 2;
const int BTN2 = 3;
const int LONG_PRESS = 1000;
int lastState = LOW;
int currentState;
unsigned long pressedTime = 0;
unsigned long releasedTime = 0;
bool isPressing = false;
bool isLongDetected = false;

int th=0; // Clock Change Hour
int tm=0; // Clock Change Minutes

void twonumbers(int z,bool boo) {
    sr.setAllLow();

  writeD1(z % 10);
  writeD2((z / 10) % 10);
  amPM(boo);
sr.updateRegisters();
}

void writeD1(int n) {
  switch (n) {
    case 0:
      sr.setNoUpdate(22, HIGH);
      break;
    case 1:
      sr.setNoUpdate(23, HIGH);
      break;
    case 2:
      sr.setNoUpdate(24, HIGH);
      break;
    case 3:
      sr.setNoUpdate(25, HIGH);
      break;
    case 4:
      sr.setNoUpdate(26, HIGH);
      break;
    case 5:
      sr.setNoUpdate(27, HIGH);
      break;
    case 6:
      sr.setNoUpdate(28, HIGH);
      break;
    case 7:
      sr.setNoUpdate(29, HIGH);
      break;
    case 8:
      sr.setNoUpdate(30, HIGH);
      break;
    case 9:
      sr.setNoUpdate(31, HIGH);
      break;
    default:
      sr.setNoUpdate(20, HIGH);
  }

}

void writeD2(int n) {
  switch (n) {
    case 0:
      sr.setNoUpdate(10, HIGH);
      break;
    case 1:
      sr.setNoUpdate(11, HIGH);
      break;
    case 2:
      sr.setNoUpdate(13, HIGH);
      break;
    case 3:
      sr.setNoUpdate(15, HIGH);
      break;
    case 4:
      sr.setNoUpdate(17, HIGH);
      break;
    case 5:
      sr.setNoUpdate(1, HIGH);
      break;
    case 6:
      sr.setNoUpdate(3, HIGH);
      break;
    case 7:
      sr.setNoUpdate(5, HIGH);
      break;
    case 8:
      sr.setNoUpdate(7, HIGH);
      break;
    case 9:
      sr.setNoUpdate(9, HIGH);
      break;
    default:
      sr.setNoUpdate(20, HIGH);
  }

}

void amPM(bool t) {
  if (t) sr.setNoUpdate(0, HIGH);
  else sr.setNoUpdate(0, LOW);
}

// RHCP on Nixie 1

void setup() {
  pinMode(BTN1, INPUT);
  pinMode(BTN2, INPUT);
  pinMode(BL, OUTPUT);
  digitalWrite(BL, HIGH);
  pinMode(EN, OUTPUT);
  pinMode(POL, OUTPUT);
  digitalWrite(POL, HIGH);
  digitalWrite(EN, LOW);
  sr.setAllLow();
  delay(500);
  amPM(true);
  delay(750);
  sr.updateRegisters();
  amPM(false);

  rtc.refresh();
  if (rtc.hour() < 18) {
    rtc.set(0, 00, 12, 6, 2, 5, 18);
    //  RTCLib::set(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)

  }

}

void loop() {
  currentState = digitalRead(BTN1);
    if(lastState == HIGH && currentState == LOW)        // button is pressed
      pressedTime = millis();
    else if(lastState == LOW && currentState == HIGH) { // button is released
      releasedTime = millis();
  long pressDuration = releasedTime - pressedTime;
  if(pressDuration > LONG_PRESS)
    isLongDetected = true;
  }
  lastState = currentState;

  
  if(digitalRead(BTN1) == HIGH){
    tellTime();
  }
  while(isLongDetected = true){
    settime();
  }
}


void tellTime() {
  sr.setAllLow();
  digitalWrite(EN, HIGH);
  

  rtc.refresh();
  twonumbers(rtc.hour(), false);
  //writeD1(rtc.hour()%10);
  //writeD2((rtc.hour()/10)%10);

  delay(1500);
  sr.setAllLow();

  twonumbers(rtc.minute(),true);
  //writeD1(rtc.minute()%10);
  //writeD2((rtc.minute()/10)%10);

  delay(1500);
  sr.setAllLow();
  digitalWrite(EN, LOW);
}

void nuke(int iterations) {
  digitalWrite(EN, HIGH);
  for (int x = 0; x <= iterations; x++) {
    for (int i = 0; i < 10; i++) {
      sr.setAllLow();
      writeD1(i);
      writeD2(9 - i);
      sr.updateRegisters();
      delay(250);
    }
  }
  digitalWrite(EN, LOW);
}


void settime(){
  amPM(true);
  digitalWrite(EN, HIGH);
  sr.setAllLow();
  writeD1(th%10);
  writeD2((th/10)%10);

  delay(200);
  if(digitalRead(BTN1) == HIGH){
    
    if(th<23){
      th++;
    }
   if(th==23){
      th = 0;
    }
  }
  if(digitalRead(BTN2) == HIGH){
    
    sr.setAllLow();
    writeD1(tm%10);
    writeD2((tm/10)%10);
    delay(200);
    if(digitalRead(BTN1) == HIGH){
      if(tm<59)
        tm++;
      if(tm==59)
        tm=0;
      }
    if(digitalRead(BTN2) == HIGH){
      rtc.set(00, tm, th, 6, 2, 5, 18);
      amPM(false);
      sr.setAllLow();
      digitalWrite(EN,LOW);
      isLongDetected = false;
    }
  }
}

Credits

Dishy
1 project • 4 followers
Contact

Comments

Please log in or sign up to comment.