Build a Binary Clock with Elixir and Nerves (PragProg)

Frank Hunleth @fhunleth
Bruce A. Tate @redrapids

edited by Jacquelyn Carter @jkcarter

Want to get better at coding Elixir? Write a hardware project with Nerves. As you build this binary clock, you’ll build in resiliency using OTP, the same libraries powering many commercial phone switches. You’ll attack complexity the way the experts do, using a layered approach. You’ll sharpen your debugging skills by taking small, easily verified steps toward your goal. When you’re done, you’ll have a working binary clock and a good appreciation of the work that goes into a hardware system. You’ll also be able to apply that understanding to every new line of Elixir you write.

Combining software with hardware can be frustrating, but you can become proficient in no time by taking a simple, logical approach. Blinking a single LED is the traditional “hello-world” of embedded systems. Building your own binary clock is the logical next step. It blinks groupings of LEDs based on the system time. This guide walks you through a working project using the techniques used by experts who build software for hardware every day.

This common sense project moves forward in tiny, logical steps. As you progress, you can verify each step before moving on to the next. You don’t have to be a Nerves novice to benefit from this project. Become a better Elixir programmer as you build your own desktop showpiece. With a layered approach to software design, you’ll learn to control the complexity of your programs the way the experts do by focusing on one small slice of your system at a time.

When you’re done, you’ll have your own binary clock, and also more of the tools you need to design and build your own Nerves and Elixir projects. You’ll also be a better programmer with a deeper appreciation of layering techniques for controlling complexity.

Frank Hunleth is an embedded systems programmer, OSS maintainer, and Nerves core team member. When not in front of a computer, he loves running and spending time with his family.

Bruce Tate is a kayaker, programmer, and father of two from Chattanooga, Tennessee. The author of more than 10 books has been around Elixir from the beginning. He is the founder of Groxio, a company that trains Elixir developers.

Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “" at checkout :+1:


This looks very interesting, but I have not yet bought the book. Why? Well, after searching online for raspberry PI homemade clocks I found a plethora of devices - some look amazing and I would definitely put them on my desk, while others … not so much.

Has anyone finished this book? Can anyone share photos of their clocks?
Does the book help you do other things as well? (Other than a clock, does it cover other areas of interest with Nervers?)

I don’t know how to work metal nor wires by the way, I am not sure if this is relevant.

During the course of working on this book, I learned that Bruce really enjoys working with wood and had a lot of fun with that aspect. However, this is not a wood working or metal working book.

The focus is on designing embedded software using Elixir. It’s important to view the binary clock as an example project. If you were only interested in building a binary clock, Nerves and Elixir are overkill. However, the binary clock is a place to start if you’re looking to learn the basics and how to build your programs for larger embedded projects.

The Weather Station book is similar, but takes a different view at the software and focuses on reporting and displaying sensor data. In that case as well, you won’t have a full fledged weather station at the end, but you will know quite a bit more on the software side.

Since it sounds like you’re interested in the end product looks, I think that you’d be more satisfied not buying the book and instead following the build instructions for a Raspberry Pi clock you like. Perhaps the programming language doesn’t matter. Or maybe you can install Nerves Livebook and write a small notebook to control it. If you’d like to see how to move your project to be a self-contained firmware image with Nerves and pull in networking and more all in Elixir, these books will help. You’ll hopefully feel better about buying them then, too.

Hope this helps.