Main Content

The Circle of Life (a digitless, pixeldust clock)

Measuring time using rhythms, pulses and gravity with an animated 32x32 RGB LED matrix

The Circle of Life
Entropy dictates that all ordered structures will eventually collapse. This includes the collapse of life. Hope, then, hangs on the cycles of creation and destruction, allowing for the resiliency of life.

Water, earth, light and heat, the pillars on which life rests, pulse with specific rhythms, creating cycles that begin and end. These cycles and rhythms are what we use to measure the passage of time.

The Object of Design
Water, or rather ice water, pulses every second, depositing a water particle on top with every pulse. Every ten seconds, a new layer is started, causing all the previous layers to warm up, darkening as a result. Every 60 seconds, the whole ice water structure collapses under its own weight, creating a new cycle.

Earth, or rather lava, as the source of primal earth, pulses every second when the water pulse hits the ground. Every minute, a lava particle is deposited on top. Every 10 minutes, a new layer of lava is started, causing all the previous layers to cool down, darkening in the process. Every 60 minutes, the whole cooled lava structure collapses under its own weight, starting again.

Life, in the form of green structures, pulses every second when the pulses of water and earth hit the ground. Every hour, a new life unit is deposited on top. Every 3 hours, a new layer of life units begins, causing all previous layers to grow older, darkening as a result. Every 12 hours, all layers of life collapse, allowing for a new cycle to begin.

Finally, the sun (light & heat) completes a full cycle every 24 hours, starting at the top as a bright (orange) AM period and crawling to the bottom as a dim (purple) PM period.

I’m using the Adafruit MatrixPortal M4 which has a Cortex M4 processor, with an ESP32 co-processor, a LIS3DH accelerometer and several pins and connectors for expansions. For a LED Matrix, I chose the 32x32 RGB LED Matrix Panel with 4mm Pitch. Out of Adafruit’s comprehensive learning guide for their MatrixPortal, the three key steps are on preparing the MatrixPortal,using it with the Arduino IDE and installing the required libraries. More details on how the LED matrix works.

Other pieces of hardware will be added for more services (see “Coming Episodes”, below)

Prose in C++
I used to edit using Visual Studio Code (free, open source and full of features) and compile, upload & serial monitor using (the now legacy) Arduino IDE 1.8 (by selecting an external editor under preferences, which keeps the files in sync). But, with the release of Arduino IDE 2.0, this changed. Now I have better autocompletion, pop-up help on functions & variables, simultaneous use of serial monitor and plotter, and many others. Plus, it looks awesome in dark mode.

When starting a new project, I find it a good practice to keep all the code in a single file: this makes it easier for the IDE to find variable & function definitions (and this helps me). As I reach the first functioning draft (because writing code as a hobby is an iterative process I enjoy), I then move certain groups to specific files to keep it all nice & tidy. Plus, this also allows me to access different points in the project with a single click (by selecting the relevant tab) instead of scrolling up & down incessantly.

I don’t have to follow an orthodox C++ file naming scheme because the Arduino IDE performs a few transformations during the sketch build process that allow for greater flexibility. Just know that all.ino files in the sketch folder are concatenated together starting with the matching folder name and then in alphabetical order. To avoid using names in alphabetical order, I use.h extensions and #include them in the main (and only).ino file.

You’ll notice also that I use comments liberally. When I revisit a project, days or weeks later, this lets me recall, understand, and follow who does what and why.”

Link to article