Turn a VFD 1970s Calculator Into a Digital Clock

by Ahmed_Ragab in Circuits > Reuse

4614 Views, 28 Favorites, 0 Comments

Turn a VFD 1970s Calculator Into a Digital Clock

VFD 1970s calculator turned into a vintage digital clock
F5MHBZ9KUTTA2ND.jpeg
FR52UQYKUTTA2T5.jpeg
IMG_20211005_092901_1.jpg
IMG_20211005_093106.jpg

So, Do you have one of these old and awesome 70s calculators?

How about giving it a new role ?

In this instructable we are going to turn an old VFD calculator into a digital clock, using the same display and case and most of the calculator's original circuit but with some extra electronics that we need to add.

If you are having the same model that I will be using in this article (ibico 066 V1) then you can just follow the steps without any problems, but if you have another model then you can use the following steps as a general guide and do some minor modifications to fit with your calculator.

github repository to find all of the project files in:

https://github.com/AhmedRagabS/VFD-Calculator-into-a-digital-clock

Supplies

Supplies might differ according to how you will do this hack but generally, I used the following tools:

  1. UT61E multimeter
  2. UTD2052CL Oscilliscope
  3. 40W Soldering Iron
  4. PCB etching and fabrication tools (depends on how you do your PCBs)
  5. Laptop with Arduino IDE installed on
  6. Electronic components (The complete BOM is in the project github repository)

How to Start This Hack

IMG_20211005_093213.jpg
IMG_20211005_093229.jpg
IMG_20211005_093240.jpg
IMG_20211005_100355.jpg
IMG_20211005_104458.jpg
IMG_20211013_135639.jpg
IMG_20211016_204440.jpg
IMG_20211016_204625.jpg

Most of these 70s VFD calculators consist of common main parts:

  1. A VFD (Vacuum Fluorescent Display)
  2. Battery compartment
  3. Microcontroller
  4. Step-up transformer
  5. Keypad PCB

You need to identify these components in your chosen model in order to modify your calculator.

  1. The VFD can be from many technological generations as seen in this link , You don't have to worry about driving the VFDs because we will leave this job to the original calculator's Microcontroller and electronics, And for not making this instructable too long you can see how VFDs work here.
  2. The battery compartment is necessary for you to know at what voltage can you operate the calculator because we are going to supply power for the main board of the calculator using our own circuit not by the original battery compartment, So you need to know if it's operated at 3V or 5V or other voltages, In my case it had 4 AA Batteries and when tested on a variable power supply the (ibico 066 V1) model that I chose could work between 3V and 6V, So I chose to operate it at 5V, If your calculator is working with only 2 AA Batteries then you will have to add a 3.3V Voltage regulator to your power supply circuit for powering the main calculator board (discussed in detail in step 4).
  3. The microcontroller can be from different companies and it will be hard to find a datasheet for it, But it will not be that much of a headache for this hack because we will not be interfacing directly with it.
  4. The step-up transformer is used to generated the high voltage needed to drive the Vacuum Fluorescent Display, and you need to keep the added electronics away from interfacing with any of these voltages.
  5. The keypad PCB will be in most cases a separate PCB that is connected to the main circuit board of the calculator using some pin headers soldered on both boards and connecting them together, For us it the most important part of the calculator because this is how and where we will hack into the calculator to display time and date digits.

How Are We Going to Display Date and Time on the Display

IMG_20211013_143445.jpg
IMG_20211013_131749.jpg
IMG_20211013_143737.jpg

This can be done in different ways, The easiest and simplest way I figured out is to emulate the keys pressed on the keypad using an extra added microcontroller, these keys are same digits that we want to display as time and date.

So I replaced the keypad PCB with a new PCB that contains:

  1. Rechargeable Lithium-ion battery.
  2. IP5305 IC for charging the battery and boosting the battery voltage to 5V.
  3. DS1307 I2C RTC (Real Time Clock) IC.
  4. ATmega328P-PU with Arduino UNO bootloader.
  5. PC817 Optocouplers, these will take the electrical signal from the ATmega328 and act as an electronic switch instead of the mechanical switch on the keypad, It will also provide isolation between the ATmega328 IC and any voltages or signals from the calculator's main board.

Schematic & PCB Files

PCB TOP.png
PCB BOTTOM.png
PCB 2D TOP.png
PCB 2D TOP_2.png
Schematic-1.png

All of the project files can be founded at the github repository of the project including:

  • Schematic design
  • PCB layout
  • Schematic design PDF
  • PCB layout PDFs for homemade PCB fabrication option
  • PCB Gerber files for factory fabrication option
  • Graphical outputs
  • Bill Of Materials
  • All of the Arduino sketches used for this project

IP5305 Charging IC

1 - USB Input and battery charging.png
1 - USB Input and battery charging MODIFIED.png
Screenshot 2021-10-16 152548.png

This IC (IP5305) Datasheet is used in many power banks, It will take a 5V USB input and charge a Lithium battery, It will also boost the battery voltage up to 5V again to be used as the power bank output, we will use this boosted 5V output to operated the ATmega328 chip, all of the added components and also power the calculator's main board that contains the calculator's microcontroller, transformer and VFD.

The IC can charge the battery and also allow the 5V output to still work, so the clock will not turn off when battery is being charged

This IC can provide 1,2,3&4 battery status indication LEDs, 1 push button to turn on and off the output 5V and a flashlight LED, In the primary schematic I intended to use all of these features but for the sake of saving some space i only used 1 battery status LED and decided not to use the push button or the flashlight LED.

Try to use at least 1000mA Lithium battery in order to not destroy of shorten the battery life-time because the charging current of the IC is 1.0A.

I used a CGR18650 D Panasonic 2350mA Lithium-ion battery extracted from an old laptop battery.

It is recommended to use a 2.2uH inductor with Idc>2A and Rdc<0.05 Ohm, I used this 22uH inductor because it was the one available locally.

Main Switch and Dummy Load Resistor

2 - Main switch.png
4 - Dummy load resistor.png
Screenshot 2021-10-16 153732.png
IMG_20211005_094228.jpg
IMG_20211013_135901.jpg
IMG_20211013_141231.jpg

For turning on and off the clock, I repurposed the calculator main switch.

  1. Desolder the 2 wires of the main switch from the calculator's main board and short the switch pads on the board using a small piece of wire.
  2. Connect the switch using two longer wires to the switch pads on the added PCB

See step 11 for more details on that.

The dummy load resistor is added maintain a minimum value of current consumption on the 5V output rail if the current consumption of the added circuit and the calculator circuit combined are lower than the shut-off threshold of the IP5305 IC, I did not solder this IC in my case because the current consumption was 68 mA which is above the threshold value.

Real Time Clock IC DS1307

3 - RTC.png

I used the DS1307 I2C RTC IC for keeping the time and date and calculating them even if the clock is turned off.

The IC used an external coin cell battery to keep a secondary power supply in case of the primary 5V supply is shut off and uses an external 32.768kHz crystal oscillator as clock source.

for more accurate real time source you can use DS3231 which uses an internal temperature compensated crystal oscillator that keeps the time drift much lower than the DS1307 which uses an external one.

Keypad Interfacing

Screenshot 2021-10-16 232129.png
5 - Keypad.png
6 - Optocouplers switching.png
6 - Optocouplers switching MODIFIED.png
Screenshot 2021-10-16 202735.png
IMG_20211005_093229.jpg
IMG_20211005_104922.jpg
IMG_20211005_104935.jpg

This is the most important step of the whole instructable, It is how the ATmega328 microcontroller display the time and date fetched from the RTC chip on the calculator display.

If you are familiar with how and Arduino uses a 4x4 keypad for example then you already know that the keypad is divided into two sets of pins (Columns pins and Rows pins).

The Arduino sends a scanning pulses/signals on one of the pins sets (Columns or Rows) and waits to see if these signals are read/received on the other pins set, If a key is pressed this means that it connects between a scanning signal and the receiving pin so the Arduino knows which key is pressed because each key has a unique (Column, Row) position so it has a unique scanning signal pin and a receiving pin.

more on this topic here & here.

This is how the calculator Microcontroller scans its keypad also, But you will have to identify the columns and rows pins and know the (Column, Row) combination of the following keys (0,1,2,3,4,5,6,7,8,9,.(Decimal point), C (Clear key)).

The scanning signal pins in my case where the pins connected to the upper plastic sheet that is placed over the PCB and soldered to it through 4 connections, and the receiving pins where connected on the PCB as copper traces.

Once you figure out all of the required keys combinations then you can use an optocoupler to act as a key press between the two pins of the key instead of mechanically pressing the key and connecting the two pins.

So let's say we want to display time 11:05:32, The ATmega chip will:

  1. Activate the ('C') key optocoupler to clear the display then deactivates it to release the key.
  2. Activate the ('1') key optocoupler then deactivates it twice.
  3. Activate the ('.') key optocoupler to isolate between hours and minutes digits then deactivates it.
  4. Activate the ('0') key optocoupler then deactivates it.
  5. Activate the ('5') key optocoupler then deactivates it.
  6. Activate the ('0') key optocoupler to isolate between the minutes and seconds digits then deactivates it.
  7. Activate the ('3') key optocoupler then deactivates it, I decided to only display the seconds in 10's format to reduce the refresh times of the display (It was not that pretty when it had to refresh the display each second to update the seconds digits).

In the primary schematic design I wanted to use a separate Current limiting resistor for each optocoupler input, but to save space I used a single resistor between optocouplers' common cathode pins and the circuit ground, It should be working fine because the code will activate only one optocoupler at a time.

Main Microcontroller ATmega328P-PU

7 - ATmega328P-PU .png

And last but not least, the ATmega328P-PU microcontroller part.

It is a bare minimum Arduino Uno configuration that includes bypass capacitors, 16MHz crystal oscillator and reset pin pull-up resistor. More on the bare minimum configuration of an ATmega328 microcontroller here.

It has an input push button to switch into date display mode instead of time display mode, UART connections to program the IC on-board using a USB to UART converter or and Arduino UNO board that has no ATmega328 chip placed on it.

It also defines which ATmega328 pins are connected to which digit optocoupler.

PCB Design

PCB TOP.png
PCB BOTTOM.png
PCB 2D TOP.png
PCB 2D TOP_2.png

Once you have determined your calculator model parts mentioned in (step 1), mapped all of the keypad keys to their associated pins as in (step 7) and did all of the PC Software and breadboard simulations that you need to, you can start designing your PCB board.

Things to mind while designing the PCB:

  1. How it will be attached to the calculator case.
  2. Lithium-ion battery size and hence battery holder size.
  3. PCB Dimensions and maximum height.
  4. Fabrication whether it will be homemade or sent to a PCB fab house.

I did my PCB design using Altium Designer software, The PCB Dimensions are 80*89 mm and chose to use an 18650 Lithium-ion battery.

the current consumption of the circuit is 68mA so the chosen 2350mA battery can operate it between 24 to 34 hours depending on the IP5305 efficiency and the battery health and actual capacity.

PCB Fabrication

IMG_20211013_133142.jpg
IMG_20211013_132934.jpg
IMG_20211012_150541.jpg
IMG_20211012_150526.jpg
IMG_20211013_110815.jpg
IMG_20211013_110826.jpg

After finishing the PCB design and fabricating your PCB either using DIY methods or sending it to a fab house you can start soldering components.

My advice is to solder each circuit block at a time a test it separately then solder the next circuit block and test it and so on

My soldering steps where as following:

  1. Solder the IP5305 Section.
  2. Make sure there is no short circuits on the power lines.
  3. Test that the battery is charging and discharging and the output voltage is 5V.
  4. Remove the battery to complete soldering.
  5. Solder the DS1307 RTC IC and the coin cell battery holder.
  6. Make sure there is no short circuits on the RTC power lines.
  7. Solder the optocouplers and test that they are all making a good connection with PCB traces.
  8. Solder the remaining parts.
  9. Add the coin cell battery.
  10. Add the Lithium-ion battery.
  11. Turn on the switch to provide the 5V voltage for the components.
  12. Make sure there is no over-current consumption and there is no short circuits.

Downloads

Assembly

IMG_20211013_141624.jpg
IMG_20211013_143015.jpg
IMG_20211013_143031.jpg
IMG_20211013_143045.jpg

Assembly steps can vary from a calculator model to another and also vary according to your approach, but generally you can follow them as described in the pictures attached in this step.

Coding

IMG_20211013_183154.jpg

Before writing the complete code for this project, we need to test individual parts and see if there is any not working block of the circuit.

We need to test:

  1. Programming the ATmega328P-PU with a dummy code and see if it can be programmed and working as intended or not.
  2. Testing the date mode push button connection.
  3. Testing the DS1307 RTC connection.
  4. Setting the time on the DS1307 RTC.
  5. Testing if the DS1307 RTC IC is providing the correct time and date values after being programmed or not.
  6. Testing each optocoupler of each key using the ATmega328 chip and display dummy digits on the VFD and also clearing it.

After doing all of these test, we can start writing the main code of the clock and uploading it

You can find all of the test codes and the final code uploaded in the github repository.

Testing the ATmega328 Microcontroller

Screenshot (183).png

I chose to program the on-board ATmega328 chip using an Arduino UNO board with the following steps:

  1. Gently remove the existing ATmega328 chip from the Arduino board
  2. Power on the clock from the switch
  3. Connect
  • Arduino board ground to the on-board ground
  • Arduino board reset pin to the on-board reset
  • Arduino board RX pin to the on-board RX pin
  • Arduino board TX pin to the on-board TX pin

You can program it using a USB to UART converter using the same steps but instead, Connect the converter TX to the on-board RX and the converter RX to the on-board TX

After connecting the programmer, I uploaded a simple serial printing sketch to see if all of the ATmega connections on the added board are correct

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}


void loop() {
  // put your main code here, to run repeatedly:
Serial.println("HELLO WORLD");
delay(1000);
}

Testing the Date Mode Push Button

Screenshot (184).png

As the Date mode button is connected to pin 13 of the ATmega328 chip (equivalent to Arduino pin 13), I wrote a simple sketch to print out on the serial monitor if the button is pressed or released.

Note that I am using the internal pull-up resistor of the ATmega chip and the push button is active low in this case (Pressed = 0, Released = 1)

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(13, INPUT_PULLUP);
}


void loop() {
  // put your main code here, to run repeatedly:
while(!digitalRead(13)){
  Serial.println("PRESSED");
  delay(200);
}
Serial.println("RELEASED");
delay(200);
}

Testing the I2C Connection of the DS1307 RTC

Screenshot (185).png

To test if the DS1307 RTC IC is connected on the I2C bus and communicating properly you can first upload the I2C Scanner sketch in the I2CScanner library by Luis Llamas and check if the device appears in the I2C scan at the address of 0x68.

If the scanner does not show a connected device at this address then check the I2C Connections and check if the pull-up resistors of the SCL and SDA lines are well connected.

/***************************************************
Copyright (c) 2018 Luis Llamas
(www.luisllamas.es)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
 ****************************************************/
 
 #include "I2CScanner.h"


I2CScanner scanner;


void setup() 
{
	Serial.begin(9600);
	while (!Serial) {};


	scanner.Init();
}


void loop() 
{
	scanner.Scan();
	delay(5000);
}

Set the DS1307 Time

Before using the RTC chip you need to set the actual time on the chip

  1. Make sure the coin cell battery is connected on the board and the Vbat line is measuring around 3V, This battery is important to keep the time count while the board is not receiving the main 5V VCC power.
  2. Download the DS1307RTC library by Michael Margolis and import it to the Arduino IDE
  3. Download the Time library by Paul Stoffregen and import it to the Arduino IDE
  4. Upload the SetTime sketch from the DS1307RTC library

Note that the SetTime sketch will automatically program the RTC Time to the time of your PC indicated by the compiler so you don't need to manually set the time

//File -> Examples -> DS1307RTC -> ReadTest


#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>


const char *monthName[12] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};


tmElements_t tm;


void setup() {
  bool parse=false;
  bool config=false;


  // get the date and time the compiler was run
  if (getDate(__DATE__) && getTime(__TIME__)) {
    parse = true;
    // and configure the RTC with this info
    if (RTC.write(tm)) {
      config = true;
    }
  }


  Serial.begin(9600);
  while (!Serial) ; // wait for Arduino Serial Monitor
  delay(200);
  if (parse && config) {
    Serial.print("DS1307 configured Time=");
    Serial.print(__TIME__);
    Serial.print(", Date=");
    Serial.println(__DATE__);
  } else if (parse) {
    Serial.println("DS1307 Communication Error :-{");
    Serial.println("Please check your circuitry");
  } else {
    Serial.print("Could not parse info from the compiler, Time=\"");
    Serial.print(__TIME__);
    Serial.print("\", Date=\"");
    Serial.print(__DATE__);
    Serial.println("\"");
  }
}


void loop() {
}


bool getTime(const char *str)
{
  int Hour, Min, Sec;


  if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
  tm.Hour = Hour;
  tm.Minute = Min;
  tm.Second = Sec;
  return true;
}


bool getDate(const char *str)
{
  char Month[12];
  int Day, Year;
  uint8_t monthIndex;


  if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
  for (monthIndex = 0; monthIndex < 12; monthIndex++) {
    if (strcmp(Month, monthName[monthIndex]) == 0) break;
  }
  if (monthIndex >= 12) return false;
  tm.Day = Day;
  tm.Month = monthIndex + 1;
  tm.Year = CalendarYrToTm(Year);
  return true;
}


Test If the RTC Is Running Correctly

Screenshot (186).png

After setting the RTC time:

  1. Switch off the calculator (Remove power from the main board) for about 2 or 3 minutes to see if the RTC can run over the secondary coin cell battery or not.
  2. Upload the ReadTest sketch from the DS1307RTC library and see if the time and date read from the RTC chip are correct.
  3. If the time is not correct, drifted or didn't count the minutes that you switched the power off during them then check the coin cell battery connections.
//File -> Examples -> DS1307RTC -> ReadTest


#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>


void setup() {
  Serial.begin(9600);
  while (!Serial) ; // wait for serial
  delay(200);
  Serial.println("DS1307RTC Read Test");
  Serial.println("-------------------");
}


void loop() {
  tmElements_t tm;


  if (RTC.read(tm)) {
    Serial.print("Ok, Time = ");
    print2digits(tm.Hour);
    Serial.write(':');
    print2digits(tm.Minute);
    Serial.write(':');
    print2digits(tm.Second);
    Serial.print(", Date (D/M/Y) = ");
    Serial.print(tm.Day);
    Serial.write('/');
    Serial.print(tm.Month);
    Serial.write('/');
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.println();
  } else {
    if (RTC.chipPresent()) {
      Serial.println("The DS1307 is stopped.  Please run the SetTime");
      Serial.println("example to initialize the time and begin running.");
      Serial.println();
    } else {
      Serial.println("DS1307 read error!  Please check the circuitry.");
      Serial.println();
    }
    delay(9000);
  }
  delay(1000);
}


void print2digits(int number) {
  if (number >= 0 && number < 10) {
    Serial.write('0');
  }
  Serial.print(number);
}

Testing the Optocouplers and Display Digits

VFD Clock digits display test

For this test, you are going to write the sketch required to:

  1. Turn on an optocoupler of a specific digit.
  2. Wait for delay of around 20 mS
  3. Turn off the optocoupler.
  4. Wait for delay of around 20 mS.
  5. Repeat the previous steps using another digit.

You might need to tweak the delay values to get the fastest refresh rate from the calculator display.

Note that the calculator microcontroller might not receive the optocoupler key press when using too low delay values.


#define D0 6
#define D1 5
#define D2 9
#define D3 8
#define D4 7
#define D5 A3
#define D6 A2
#define D7 4
#define D8 3
#define D9 2
#define DP A0
#define C A1

void display_digit(char digit);

void setup() {
 // put your setup code here, to run once:
Serial.begin(9600);

pinMode(D0, OUTPUT); digitalWrite(D0, LOW);
pinMode(D1, OUTPUT); digitalWrite(D1, LOW);
pinMode(D2, OUTPUT); digitalWrite(D2, LOW);
pinMode(D3, OUTPUT); digitalWrite(D3, LOW);
pinMode(D4, OUTPUT); digitalWrite(D4, LOW);
pinMode(D5, OUTPUT); digitalWrite(D5, LOW);
pinMode(D6, OUTPUT); digitalWrite(D6, LOW);
pinMode(D7, OUTPUT); digitalWrite(D7, LOW);
pinMode(D8, OUTPUT); digitalWrite(D8, LOW);
pinMode(D9, OUTPUT); digitalWrite(D9, LOW);
pinMode(DP, OUTPUT); digitalWrite(DP, LOW);
pinMode(C, OUTPUT); digitalWrite(C, LOW);

display_digit('C');
delay(1000);
}

void loop() {
 // put your main code here, to run repeatedly:
display_digit('1');
delay(2000);

display_digit('.');
delay(2000);

display_digit('2');
delay(2000);

display_digit('3');
delay(2000);

display_digit('4');
delay(2000);

display_digit('5');
delay(2000);

display_digit('6');
delay(2000);

display_digit('C');
delay(2000);

display_digit('7');
delay(2000);

display_digit('8');
delay(2000);

display_digit('9');
delay(2000);

display_digit('0');
delay(2000);

display_digit('C');
delay(2000);

}

void display_digit(char digit){
 switch(digit){
  case '0': digitalWrite(D0, HIGH); delay(20); digitalWrite(D0, LOW); delay(20); break;
  case '1': digitalWrite(D1, HIGH); delay(20); digitalWrite(D1, LOW); delay(20); break;
  case '2': digitalWrite(D2, HIGH); delay(20); digitalWrite(D2, LOW); delay(20); break;
  case '3': digitalWrite(D3, HIGH); delay(20); digitalWrite(D3, LOW); delay(20); break;
  case '4': digitalWrite(D4, HIGH); delay(20); digitalWrite(D4, LOW); delay(20); break;
  case '5': digitalWrite(D5, HIGH); delay(20); digitalWrite(D5, LOW); delay(20); break;
  case '6': digitalWrite(D6, HIGH); delay(20); digitalWrite(D6, LOW); delay(20); break;
  case '7': digitalWrite(D7, HIGH); delay(20); digitalWrite(D7, LOW); delay(20); break;
  case '8': digitalWrite(D8, HIGH); delay(20); digitalWrite(D8, LOW); delay(20); break;
  case '9': digitalWrite(D9, HIGH); delay(20); digitalWrite(D9, LOW); delay(20); break;
  case '.': digitalWrite(DP, HIGH); delay(20); digitalWrite(DP, LOW); delay(20); break;
  case 'C': digitalWrite(C, HIGH); delay(20); digitalWrite(C, LOW); delay(20); break;
 }
 Serial.println(digit);
}

Final Code

Now and finally after testing all of the project hardware and software block, you are ready to write and upload the final clock code.

Simply the final sketch needs to:

  1. Read the date and time from the RTC chip.
  2. Save the time data string and the date data string
  3. Update the display with the time value string each 10 seconds.
  4. If the date mode button is pressed then display the date value string for a certain delay time then switch back to the time value display again.
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>


//Pinouts as mapped from the schematic
#define D0 6
#define D1 5
#define D2 9
#define D3 8
#define D4 7
#define D5 A3
#define D6 A2
#define D7 4
#define D8 3
#define D9 2
#define DP A0
#define C  A1


#define PushButtonPin 13


void display_number(const char *p); //The function that handles the displayed string and converts it to single charcaters to get displayed
void display_digit(char digit); //The final display output function


int hour_data = 0;
int minute_data = 0;
int second_data = 0;


int day_data = 0;
int month_data = 0;
int year_data = 0;


char time_data[7];
char date_data[7];


//Variables needed to make a 10 seconds delay for the display without using delay();
long start_count_millis = 0;
int maximum_millis_delay = 9700;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);


pinMode(D0, OUTPUT); digitalWrite(D0, LOW);
pinMode(D1, OUTPUT); digitalWrite(D1, LOW);
pinMode(D2, OUTPUT); digitalWrite(D2, LOW);
pinMode(D3, OUTPUT); digitalWrite(D3, LOW);
pinMode(D4, OUTPUT); digitalWrite(D4, LOW);
pinMode(D5, OUTPUT); digitalWrite(D5, LOW);
pinMode(D6, OUTPUT); digitalWrite(D6, LOW);
pinMode(D7, OUTPUT); digitalWrite(D7, LOW);
pinMode(D8, OUTPUT); digitalWrite(D8, LOW);
pinMode(D9, OUTPUT); digitalWrite(D9, LOW);
pinMode(DP, OUTPUT); digitalWrite(DP, LOW);
pinMode(C,  OUTPUT); digitalWrite(C,  LOW);


pinMode(PushButtonPin, INPUT_PULLUP);


display_digit('C'); //Clear the display before the main function starts
delay(500);
}


void loop() {
  // put your main code here, to run repeatedly:
  
// Store RTC data into variables and display them every 10 seconds
if ( (millis() - start_count_millis > maximum_millis_delay)||(millis()<=1500) ){
start_count_millis = millis();
tmElements_t tm;
  if (RTC.read(tm)) {
    hour_data = tm.Hour;
    (hour_data > 12) ? (hour_data -= 12) : (hour_data = hour_data); //comment this line to display in 24H mode
    minute_data = tm.Minute;
    second_data = tm.Second/10; //display seconds in multiples of 10
    day_data = tm.Day;
    month_data = tm.Month;
    year_data = tmYearToCalendar(tm.Year)-2000;
    
    //Format all the time collected data into a char array named (time_data) then display this array on the VFD Display
    sprintf(time_data,"%02d.%02d0%d",hour_data,minute_data,second_data);
    Serial.println(time_data);
    display_digit('C');
    display_number(time_data);


    //Format all the date collected data into a char array named (date_data) then display this array on the VFD Display when the date button is pressed
    sprintf(date_data,"%02d.%02d%02d",day_data,month_data,tmYearToCalendar(tm.Year)-2000);
    Serial.println(date_data);
  }
}


if (!digitalRead(PushButtonPin)){ //If date display button is pressed
    display_digit('C');
    display_number(date_data);
    delay(3000); //for the date data to stay on to read then return to display time data
    display_number(time_data);
}


}


void display_number(const char *p){
  while(*p!='\0')
  {
    display_digit(*p);
    p++;
  }
}


void display_digit(char digit){
  switch(digit){
    case '0': digitalWrite(D0, HIGH); delay(20); digitalWrite(D0, LOW); delay(20); break;
    case '1': digitalWrite(D1, HIGH); delay(20); digitalWrite(D1, LOW); delay(20); break;
    case '2': digitalWrite(D2, HIGH); delay(20); digitalWrite(D2, LOW); delay(20); break;
    case '3': digitalWrite(D3, HIGH); delay(20); digitalWrite(D3, LOW); delay(20); break;
    case '4': digitalWrite(D4, HIGH); delay(20); digitalWrite(D4, LOW); delay(20); break;
    case '5': digitalWrite(D5, HIGH); delay(20); digitalWrite(D5, LOW); delay(20); break;
    case '6': digitalWrite(D6, HIGH); delay(20); digitalWrite(D6, LOW); delay(20); break;
    case '7': digitalWrite(D7, HIGH); delay(20); digitalWrite(D7, LOW); delay(20); break;
    case '8': digitalWrite(D8, HIGH); delay(20); digitalWrite(D8, LOW); delay(20); break;
    case '9': digitalWrite(D9, HIGH); delay(20); digitalWrite(D9, LOW); delay(20); break;
    case '.': digitalWrite(DP, HIGH); delay(20); digitalWrite(DP, LOW); delay(20); break;
    case 'C': digitalWrite(C,  HIGH); delay(20); digitalWrite(C,  LOW); delay(20); break;
    default : digitalWrite(D0, HIGH); delay(20); digitalWrite(D0, LOW); delay(20); break;
  }
  Serial.println(digit);
}


Final Project

VFD 1970s calculator turned into a vintage digital clock
F7QNDMSKUTTA2T6.jpeg
VFD Clock charging test

And here it is, Ready for its new role and happily sitting on my desk.

Time format is : HH.MM0S which was in the first video [ 11.2603, 11.2604, 11.2605, 11.2700, 11.2701 ]

Date format is : DD.MMYY which was in the video [ 16.1021 ]