倒计时你生命中剩余的年份/天数/秒数。
Countdown the years, days, and seconds remaining in your life — on a small Arduino-powered LCD.
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.
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.
The sketch is small and self-contained
(carpe_diem_clock/carpe_diem_clock.ino).
Each second it:
FINAL_EPOCH_TIME_SECONDS) to get the seconds remaining.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.
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.
If you don't already have an Arduino or display, I'd recommend Adafruit.
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). |
The countdown starts as soon as the board boots.
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.
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.
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.
Issues and pull requests are welcome — especially for the modifications above.
Released under the GNU General Public License v3.
暂无开放 Issues,或尚未同步最近议题。