Code

last modified: October 23, 2025

Candlelight Emulation – Complexity with Layering

Posted on 2023-02-01— Projects

I explain microcontroller firmware that emulates candlelight using layered, low-resource random waves and simple integer math. I cover color gradients, LED mapping (WS2812B), and flicker modulation so constrained boards can produce organic light. If this interests you, please read the full post for code and details.

Read this post

Three Ways to Integrate LED Light Into the Modular Lantern

Posted on 2023-01-29— 3D Printing, Build, Projects

I tested three inexpensive, easy methods to add LED lighting to my modular 3D‑printed lantern using USB power: reused LED modules, short 5V strips, and WS2812B RGB with a microcontroller. I share parts lists, soldering tips, diffuser advice, and firmware steps—read on for step‑by‑step instructions and printable models.

Read this post

Filtered RPM Measurement Using PIO

Posted on 2021-04-17— Learn, Software

I walk you through using the RP2040's PIO to measure a PC fan's RPM with a small software filter to ignore short spikes and timeouts. I explain the PIO routine and a simple RpmInput wrapper in MicroPython—read on if you'd like the code and practical setup tips.

Read this post

Event-Based Firmware Example

Posted on 2019-08-05— C++, Improve your Code, Learn

I provide a complete event-loop firmware example for SAM‑D boards (Arduino Zero, Feather M0). I explain module design—Buttons, Display, and a support library—initialisation and polling logic, and link the source and demo. If you're curious, read the full post for code and implementation notes.

Read this post

C++ Templates for Embedded Code (Part 2)

Posted on 2019-07-27— C++, Improve your Code, Learn

I continue exploring C++ templates for embedded systems, showing template classes, pin abstraction, and combining Sender and Pin examples to reduce firmware size and improve code clarity. I explain static methods, type aliases, and trade-offs between runtime flexibility and efficiency. Read the full post to see code and assembly comparisons.

Read this post

Bit Manipulation using Templates

Posted on 2019-07-23— C++, Improve your Code, Learn

I explore replacing unsafe bit macros with lightweight C++ templates to make embedded bit operations safer and clearer. I show templates for one-bit extraction, set/clear helpers, and compiled firmware size for Arduino Uno. Read the full post to see examples, exercises, and practical benefits.

Read this post

C++ Templates for Embedded Code

Posted on 2019-07-20— C++, Improve your Code, Learn

I walk through C++ templates for embedded projects, showing how function templates work, why they’re type-safe, and how they can keep firmware small and fast. Using Arduino examples like circularShift, reverseBits and a template-based Sender, I invite you to read the full post to learn practical tips and patterns.

Read this post

Auto and Structured Binding

Posted on 2019-07-16— C++, Improve your Code, Learn

I introduce C++17 structured binding with approachable examples: returning multiple values via std::tuple, binding to structs and arrays, and using references to avoid copies. If you use a C++17-capable compiler and want cleaner, clearer code, read the full article for practical examples and tips.

Read this post

Guide to Modular Firmware

Posted on 2019-07-14— C++, Improve your Code, Learn

I wrote a concise guide for embedded developers to refactor Arduino/C++ firmware into clean, modular components. I walk you through creating Display, Buttons, and Animation modules, testing and committing small changes, and improving maintainability. If you'd like practical steps and examples, please read the full article.

Read this post

It's Time to Use #pragma once

Posted on 2019-07-13— C++, Improve your Code, Learn

I explain why I prefer #pragma once over macro header guards and how it prevents subtle build errors and wasted debugging time. I’ll show examples, common pitfalls, and practical steps to replace guards in existing projects — read on if you want a simple, low-risk improvement.

Read this post

Write Less Code using the "auto" Keyword

Posted on 2019-07-12— C++, Improve your Code, Learn

I walk through practical ways I use C++11's auto keyword to reduce repetitive declarations, simplify range-based for loops, lambdas and register access, and make Arduino and embedded code easier to refactor. Read the full post for examples and tips you can apply to your projects.

Read this post

Units of Measurements for Safe C++ Variables

Posted on 2019-07-11— C++, Improve your Code, Learn

I show how I avoid unit mistakes in C++ by creating a templated Duration type and user-defined literals like 100_ms. I explain declaring Seconds/Milliseconds/Nanoseconds, adding conversions, and how the compiler catches unit mismatches with no runtime cost. Read the full article for code examples and the GitHub repo.

Read this post

Class or Module for Singletons?

Posted on 2019-07-09— C++, Improve your Code, Learn

I compare implementing a singleton as a class or as a module/namespace for Arduino firmware using simple LED driver examples and compiler measurements. I cover size, initialization and runtime trade-offs and explain when each approach makes sense. Read the full post for code, disassembly and practical recommendations.

Read this post

Inline AES 256 / CBC Implementation

Posted on 2019-04-14— Common, Software

I created a readable, fully inline AES‑256/CBC implementation you can drop into C++ projects — handy for embedded systems. It avoids static S‑Boxes, needs only stdint/cstddef, and is MIT‑licensed on GitHub. If this sounds useful, read the full post for requirements, example code, and usage notes.

Read this post

How to Deal with Badly Written Code

Posted on 2018-08-31— C++, How and Why, Improve your Code

I often encounter poorly written C++ libraries, especially around hardware. In this post I outline four practical strategies—rewrite, refactor, wrap the library, or wrap the interface—to regain control, improve reliability, and reduce pain. Read on for pragmatic steps and examples you can apply to your projects.

Read this post

Make your Code Safe and Readable with Flags

Posted on 2018-05-06— C++, Improve your Code

I show how a small C++ flags template makes embedded register bitmasks safer and much easier to read. I'll explain why macros and CMSIS-style definitions lead to errors, and walk through clear C++11 examples and a simple driver. Read on to see the implementation and usage.

Read this post

How to Design a Cheap Plant Watering Sensor (Part 4)

Posted on 2017-03-04— How and Why

I guide you through writing a near-final firmware for my cheap plant watering sensor, describing module structure, incremental development, and practical tests. I cover ADC sampling, oscillator checks, EEPROM settings and a prototype fix for the push-button. If you’re building a similar device, I invite you to read the full post.

Read this post

Lucky World – A jump'n'run game for MeggyJr RGB

Posted on 2014-12-17— Common

I've released Lucky World, a compact jump'n'run for the MeggyJr RGB featuring an intro, 16+ levels, secrets and an end scene. I squeezed it into ATmega328P limits and shared the sources under GPLv2. If you're curious, please read on for downloads, requirements, and play instructions.

Read this post

Source Code for Xmas Decoration on GitHub

Posted on 2014-12-01— Common

I documented the source code for my color-changing Xmas decoration and pushed it to GitHub, adding comments and safety notes about parts you shouldn't copy. If you're curious about the implementation or want to build your own, please view the repository and the full project description for details.

Read this post

How to Debug Time Critical Code using an Oscilloscope

Posted on 2014-11-13— How and Why

I often use a simple oscilloscope trick to debug time-critical code: toggle an I/O line before and after critical sections and observe interrupt timing and execution width. It’s low-effort and revealing — read on for practical steps, examples, and tips to measure and reason about your timing issues.

Read this post