Skip to content

pisco-de-luz/Pisco-Code-Arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pisco Code — Arduino Library

License: MIT

Pisco Code encodes decimal, hexadecimal, or binary values as LED blink patterns using a single status LED. No serial port or display needed.

This is the Arduino-compatible distribution of the Pisco Code library. It is automatically generated from the main repository on each release.

⚠️ Requires C++17 — Works out of the box with ESP32, RP2040 (Pico), STM32, SAMD, ESP8266 and other boards whose toolchain defaults to C++17.
Other boards (e.g. Arduino AVR) can be used by enabling C++17 manually — see Enabling C++17 on older boards below.

Installation

Arduino IDE Library Manager

  1. Open Arduino IDE
  2. Go to Sketch → Include Library → Manage Libraries…
  3. Search for Pisco-Code
  4. Click Install

Manual Installation

  1. Download the latest release .zip from Releases
  2. In Arduino IDE: Sketch → Include Library → Add .ZIP Library…

Quick Start

#include <Pisco-Code.h>

bool ledOnboard(pisco_code::LedControlCode code)
{
    switch (code)
    {
        case pisco_code::LedControlCode::ON:
            digitalWrite(LED_BUILTIN, HIGH);
            return true;
        case pisco_code::LedControlCode::OFF:
            digitalWrite(LED_BUILTIN, LOW);
            return true;
        default:
            return false;
    }
}

pisco_code::LedControllerSoftwarePwm controller(ledOnboard);
pisco_code::SignalEmitter             emitter(controller);

void setup()
{
    pinMode(LED_BUILTIN, OUTPUT);
    emitter.showCode(
        pisco_code::SignalCode{103},
        pisco_code::Radix::DEC,
        pisco_code::NumDigits{0});
}

void loop()
{
    emitter.loop();
    delay(1);
}

How It Works

Most embedded projects lack a convenient way to observe internal variables — serial ports, debuggers, or displays aren't always available. Pisco Code solves this by encoding values as LED blink patterns that anyone can read by eye.

The Problem with Simple Blink Counting

A common approach is to blink an LED n times to represent the value n. For multi-digit numbers like 312, you blink 3 times, pause, 1 time, pause, 2 times:

code312.png

This works — but breaks down for zeros (how do you blink 0 times?) and can be hard to follow.

The Pisco Code Solution

Pisco Code adds a framing signal — a dim glow before each digit sequence begins. This makes every digit unambiguous, including zero:

Code 121:

Video-Code-121-132x132.gif

Code 120 (with a zero digit):

Pisco-Code-120-144x144.gif

Minimum digits (e.g. 002 for 0.02 V sensor reading):

Pisco-Code-002-144x144.gif

Negative values (-12 — long blink prefix):

Pisco-Code-Negative12-144x144.gif

Features

Feature Description
Bases Decimal, binary, hexadecimal
Negative values Long-blink prefix
Zero digits Explicit gap representation
Min digits Configurable (e.g., always show 3 digits for 0–5 V readings)
Controllers Software PWM (GPIO toggle) and Hardware PWM (smooth dimming)
Memory No dynamic allocation, no exceptions — ideal for constrained MCUs

Real-World Use

Pisco Code has been used in the Pisco de Luz project since 2020, reading battery voltage, solar panel output, temperature, and usage hours in off-grid solar lighting systems — all through a single LED.

For full documentation, architecture details, and cross-platform support (AVR, STM32, native), see the main repository.

Enabling C++17 on older boards

Some boards (e.g. Arduino AVR — Uno, Mega, Nano) ship with a toolchain that defaults to C++11. You can switch to C++17 by creating a platform.local.txt file:

  1. Find your board's platform.txt. Common locations:

    OS Path
    Windows %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\<version>\
    macOS ~/Library/Arduino15/packages/arduino/hardware/avr/<version>/
    Linux ~/.arduino15/packages/arduino/hardware/avr/<version>/
  2. In that same folder, create a new file called platform.local.txt with the following line:

    compiler.cpp.extra_flags=-std=gnu++17
    
  3. Restart the Arduino IDE and recompile.

Note: platform.local.txt overrides settings without modifying the original platform.txt, so board-manager updates won't undo your change.

Changelog

See the Changelog in the main repository.

License

MIT — see LICENSE.

About

A lightweight mechanism for encoding numeric values (positive and negative) as visual blink patterns on a single LED or actuator. Designed for embedded systems with minimal hardware resources, ideal for field diagnostics without UART or display.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors