Carpe Diem Clock
Countdown the years, days, and seconds remaining in your life — on a
small Arduino-powered LCD.
Table of contents
What is this?
A carpe diem clock. Based on an average life expectancy, you can use
this clock to countdown the time until your expected last day of life.
I use it as a regular reminder that my life has a limit; a
best-before-date. This knowledge helps me make better decisions about
how to spend my time and how I want to live with the time I have.
Why “carpe diem”?
Carpe diem — “seize the day.” The clock isn’t meant to be morbid.
It’s a nudge: the countdown is only ever an estimate, and the point of
watching it tick is to spend the time it’s counting well.
How it works
The sketch is small and self-contained
(carpe_diem_clock/carpe_diem_clock.ino).
Each second it:
- Reads the current time from the
Arduino Time library.
- Subtracts it from your configured life-expectancy timestamp
(
FINAL_EPOCH_TIME_SECONDS) to get the seconds remaining.
- Renders those seconds across two rows of a 16x2 LCD:
- Row 1 — the years remaining.
- Row 2 — the remaining days, hours, minutes, and seconds
(
123d 04:05:06).
Because a basic Arduino board has no battery-backed clock, the sketch
writes the current time to the on-board EEPROM twice a day. If the
board briefly loses power, it resumes from that saved value on the next
boot rather than resetting to zero. Writing only every 12 hours keeps
the EEPROM well within its ~100,000 write/erase-cycle lifetime — at
that rate it should last on the order of a century.
What’s my life expectancy?
We can’t know the future, so we can’t accurately predict how long
you’ll live. The next best option is to use research & statistics to
generate a probability of your life expectancy.
Here are a couple of life expectancy calculators that (I think) have
some science behind them:
Once you have a date, convert it to a Unix epoch timestamp (seconds) —
for example with epochconverter.com
— and keep it handy for the next step.
What you’ll need
- An Arduino board (I used the Uno).
- A 16x2 LC display (LCD). Almost any breadboard-friendly LCD will do.
- A breadboard and jumper wires.
- The Arduino IDE.
- The Arduino Time library,
installable from the IDE’s Library Manager.
If you don’t already have an Arduino or display, I’d recommend
Adafruit.
Build it
1. Wire up the LCD
Fortunately, someone has already put together a great set of tutorials
on setting up the LCD.
This “Hello World!” tutorial
will show you how to complete the circuit and run a test.
The sketch expects the LCD wired to the same pins as that tutorial:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
If you wire it differently, update that line to match.
Open carpe_diem_clock/carpe_diem_clock.ino and set the two constants
at the top:
| Constant |
What it is |
CURRENT_EPOCH_TIME_SECONDS |
The current Unix epoch time. Update this each time you re-upload, since the board has no way to know the real time on its own. |
FINAL_EPOCH_TIME_SECONDS |
The epoch time of your estimated last day (from the life-expectancy step). |
3. Upload
- Open the sketch in the Arduino IDE.
- Install the Time library via Tools → Manage Libraries….
- Select your board and port under Tools.
- Click Upload.
The countdown starts as soon as the board boots.
Modifications
This is easy to do just by looking at the code. You might want to
reduce the number of zeros in the years display, for example.
External power source
You probably don’t want to keep the Arduino tethered to your computer.
An external power supply (such as one from
Adafruit) lets it run on its own. Note the
limitation below about losing power.
Add a clock source
There are components you can buy to act as a clock source (like the
DS1307 crystal). Alternatively, add an ethernet or wifi connector and
sync via NTP over the internet. The
Arduino Time library that
this project uses has code examples you can pull from.
If you implement this, PRs are welcome.
Limitations
- No real-time clock. A basic Arduino can’t find the current time
by itself. If you unplug your Carpe Diem Clock, the countdown resumes
from the last value saved to EEPROM (updated every 12 hours), not
from the actual current time. Adding a
clock source fixes this.
- Approximate calendar math. The sketch treats every year as 365
days and doesn’t account for leap years or time zones, so the display
is an estimate — which is fitting, given that the life-expectancy date
is too.
Contributing
Issues and pull requests are welcome — especially for the
modifications above.
License
Released under the GNU General Public License v3.
评论