Here's a very simple clock display idea, if you already have a surplus digital counter. I like Nixie tube counters, like this HP5216A. It has a "totalize" function where it just counts input transitions, and also a TTL "reset" input on the back. Pull reset low briefly to clear the counter, then send an n-pulse burst where digits of n form the time as 'hhmmss' (so in the pic it is showing 19:36:11, or 7:36:11 pm). Teensy 3.5 is overkill here, anything with a realtime clock will work. I added an NPN transistor to do the reset (and inverted the pulse correspondingly), although it would probably work OK without that.
Here is a video (also showing T3.5 scope clock from another thread).
The code is very simple:
Here is a video (also showing T3.5 scope clock from another thread).
The code is very simple:
Code:
/*
clock display on antique frequency counter
(e.g., HP 5216A)
*/
#include <TimeLib.h>
#define pulsePin 14 // to counter input
#define resetPin 37 // to counter reset
#define ledPin 13
elapsedMillis r = 0; // update timer
void setup() {
Serial.begin(9600);
setSyncProvider(getTeensy3Time);
pinMode(pulsePin, OUTPUT);
pinMode(resetPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
long nout = 0;
if (r > 1000) {
r = 0; // reset update timer
digitalWrite(resetPin, HIGH); // send reset pulse to counter
digitalWrite(ledPin, HIGH);
digitalWrite(resetPin, LOW);
delay(30); // delay to re-arm after reset pulse
nout = 10000 * hour(); // 230000
nout += 100 * minute(); // 5900
nout += second(); // 59
if (0) nout = 235959; // (for testing)
for (long p = 0; p < nout; p++) {
digitalWrite(pulsePin, HIGH);
digitalWrite(pulsePin, LOW);
}
digitalWrite(ledPin, LOW);
if (1) { // (diagnostics)
Serial.println(nout);
printTime();
}
}
}
/*
*/
time_t getTeensy3Time() {
return Teensy3Clock.get();
}
/*
*/
void printTime() {
Serial.print(hour());
Serial.print(":");
if (minute() < 10) Serial.print('0');
Serial.print(minute());
Serial.print(":");
if (second() < 10) Serial.print('0');
Serial.print(second());
Serial.println("\n");
}
/*
FIN
*/
Last edited: