All Projects → tfeldmann → Arduino-Blinkenlight

tfeldmann / Arduino-Blinkenlight

Licence: MIT license
Non-blocking blinking patterns and smooth fade effects for your LEDs.

Programming Languages

C++
36643 projects - #6 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Arduino-Blinkenlight

Control Surface
Arduino library for creating MIDI controllers and other MIDI devices.
Stars: ✭ 377 (+1350%)
Mutual labels:  arduino-library, led
Effortless-SPIFFS
A class designed to make reading and storing data on the ESP8266 and ESP32 effortless
Stars: ✭ 27 (+3.85%)
Mutual labels:  platformio, arduino-library
Md parola
Library for modular scrolling LED matrix text displays
Stars: ✭ 282 (+984.62%)
Mutual labels:  arduino-library, led
TM1637TinyDisplay
Arduino library to display numbers and text on a 4 and 6 digit 7-segment TM1637 display modules.
Stars: ✭ 23 (-11.54%)
Mutual labels:  arduino-library, led
SuperLEDstrip
No description or website provided.
Stars: ✭ 13 (-50%)
Mutual labels:  platformio, led
Md max72xx
LED Matrix Library
Stars: ✭ 186 (+615.38%)
Mutual labels:  arduino-library, led
Ws2812fx
WS2812 FX Library for Arduino and ESP8266
Stars: ✭ 1,113 (+4180.77%)
Mutual labels:  arduino-library, led
Irremoteesp8266
Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
Stars: ✭ 1,964 (+7453.85%)
Mutual labels:  platformio, arduino-library
Arduino-Log
Simple application log library. supporting multiple log levels, custom output & flash memory support.
Stars: ✭ 132 (+407.69%)
Mutual labels:  platformio, arduino-library
Lpd8806
Arduino library for LED strips and pixels using LPD8806 (and probably LPD8803/LPD8809)
Stars: ✭ 207 (+696.15%)
Mutual labels:  arduino-library, led
Guislice
GUIslice drag & drop embedded GUI in C for touchscreen TFT on Arduino, Raspberry Pi, ARM, ESP8266 / ESP32 / M5stack using Adafruit-GFX / TFT_eSPI / UTFT / SDL
Stars: ✭ 534 (+1953.85%)
Mutual labels:  platformio, arduino-library
Easybutton
Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
Stars: ✭ 187 (+619.23%)
Mutual labels:  platformio, arduino-library
Adafruit VL6180X
Arduino library for Adafruit VL6180X
Stars: ✭ 29 (+11.54%)
Mutual labels:  arduino-library
RAK811-tracker
Example code for RAK811 nodes with GPS on board, transmitting their coordinates in the payload of the LoRaWAN packet in a format that is compatible with TTN Mapper.
Stars: ✭ 14 (-46.15%)
Mutual labels:  platformio
ZMPT101B-arduino
Arduino library for ZMPT101B voltage sensor.
Stars: ✭ 34 (+30.77%)
Mutual labels:  arduino-library
Maix-LogoClassifier
A simple logo classifier developed using Maixduino framework and PlatfomIO, to run on K210 MCU on Sipeed's Maix dev board.
Stars: ✭ 25 (-3.85%)
Mutual labels:  platformio
ESP8266 ArtNet-LED-DMX-Node
ESP8266 based WiFi ArtNet-Node for WS2812B-LED Pixel
Stars: ✭ 67 (+157.69%)
Mutual labels:  led
EUC-Dash-ESP32
Bluetooth Dashboard for electric unicycles (EUCs) for ESP32(ttgo t-watch). requires PlatformIO to build
Stars: ✭ 24 (-7.69%)
Mutual labels:  platformio
AD9850SPI
AD9850 SPI library for arduino
Stars: ✭ 20 (-23.08%)
Mutual labels:  arduino-library
Adafruit AMG88xx
AMG88xx Grid-EYE
Stars: ✭ 85 (+226.92%)
Mutual labels:  arduino-library

Arduino-Blinkenlight

tests

Featured on hackster.io!

🚨 Supercharge your status-LEDs 🚨

This library gives you non-blocking blinking patterns and smooth fade effects for your LEDs, buzzers or any other status indicators

Achtung Alles Lookenskeepers!
Das computermachine ist nicht fuer gefingerpoken und
mittengrabben. Ist easy schnappen der springenwerk,
blowenfusen und poppencorken mit spitzensparken. Ist nicht
fuer gewerken bei das dumpkopfen. Das rubbernecken
sichtseeren keepen das cotten-pickenen hans in das pockets
muss; relaxen und watchen das blinkenlichten.

Features

  • On / off / toggle
  • Infinite blinking
  • Blink patterns (for example to blink an error code)
  • Single flashes and pauses, resuming the previous mode

Other goodies:

  • Completely non-blocking (no delay())
  • Super-nice fading effects (optional) with logarithmic brightness compensation for LEDs
  • Lightweight
  • All parameters can be adjusted on the fly without visual hickups
  • Easily extendable to control components via SPI / CAN / I2C / UART ...
  • Comes with good-looking defaults (at least I tried)
  • Tries to be user friendly (for example calling blink() while blinking does not restart the cycle)
  • Supports active low (inverted) logic
  • Can be used for buzzers as well

Example

This example blinks the built-in LED on pin 13 in the following pattern:

pattern

#include <Blinkenlight.h>

Blinkenlight led(13);

void setup()
{
  led.pattern(2, 3);  // blink 2x, then 3x
}

void loop()
{
  led.update();
}

Note: If you'd love a smoother look, just use the Fadinglight-class instead of Blinkenlight. A Fadinglight has smooth fading effects with logarithmic LED brightness compensation. Your boards never looked more professional! /s

Installation

Platform.io

Blinkenlight is available in the platform.io registry

pio lib install "tfeldmann/Blinkenlight"

Arduino library manager

Blinkenlight is available in the Arduino library manager.

Blinkenlight in the Arduino library manager

Full API

Instantiation

// Without fading effect:
#include <Blinkenlight.h>
Blinkenlight myLed(13);  // Blinkenlight(int pin, bool invert = false);

// With fading effect:
#include <Fadinglight.h>
Fadinglight myLed(13);  // Fadinglight(int pin, bool logarithmic = true, int fade_speed = 30);

// now in your code you can do:
myLed.off();
myLed.blink();
myLed.pattern(3, 5, SPEED_FAST);
// ... and so on (see below)

Basic usage (what you can do with your light)

// set permanently ON
void on();

// set permanently OFF
void off();

// toggle between on / off
void toggle();

// set ON / OFF permanently
void permanent(bool enable);

// blink infinitely
void blink();
void blink(SpeedSetting speed);

// blink `num` times, then long pause
// repeats, if `repeat` is set, OFF otherwise.
void pattern(int num, bool repeat = true);
void pattern(int num, SpeedSetting speed, bool repeat = true);

// blink `num1` times, short pause, blink `num2` times, long pause
// repeats, if `repeat` is set, OFF otherwise.
void pattern(int num1, int num2, bool repeat = true);
void pattern(int num1, int num2, SpeedSetting speed, bool repeat = true);

// turn ON for the given duration in ms. Continues in the previous mode afterwards.
void flash(uint16_t duration_ms);

// turn OFF for the given duration in ms. Continues in the previous mode afterwards.
void pause(uint16_t duration_ms);

// `true` if the Blinkenlight is currently blinking, showing a pattern, flashing or pausing
bool isOn();

// You must call this in your loop!
// Returns the current value of the light (LOW / HIGH).
// - You can ignore that if you want.
int update();

Blinking speed and timing parameters

// setup the timing parameters
void setSpeed(SpeedSetting setting);

// Available by default: SPEED_RAPID, SPEED_FAST, SPEED_SLOW
myLed.setSpeed(SPEED_RAPID);
myLed.setSpeed(SPEED_FAST);
myLed.setSpeed(SPEED_SLOW);

// .. or use your own settings. SpeedSetting is a struct:
typedef struct
{
    uint16_t on_ms;         // ON time in milliseconds
    uint16_t off_ms;        // OFF time in milliseconds
    uint16_t pause_ms;      // pause between `num1` and `num2` in pattern()
    uint16_t ending_ms;     // ending after a full pattern
} SpeedSetting;

// so you can set it up like this:

SpeedSetting mySettings = {
    .on_ms = 100,
    .off_ms = 100,
    .pause_ms = 2000,
    .ending_ms = 2000,
};

// ... alternatively you can setup the speed settings directly with this method
void setSpeed(
    uint16_t on_ms,
    uint16_t off_ms,
    uint16_t pause_ms,
    uint16_t ending_ms);

// ... or by providing a single value, the other values are inferred from that by
// some internal factors
void setSpeed(uint16_t on_ms);

// Hint: You can also modify the values directly - even on the fly - e.g.:
myLed.settings.on_ms = 250;
myLed.settings.pause_ms = 2000;

Fading effect and brightness compensation

LED brightness is not linear to the PWM value you set to the pin. This library uses a logarithmic dimming curve to create natural looking fading effects.

logarithmic fading

I have a status indicator controlled via CAN / I2C / SPI / ... What can I do?

No problem! You have two options.

  • Use the generic BaseBlinker class from <BaseBlinker.h>. The .update()-method returns a boolean whether the status is currently HIGH or LOW. You can then send this value to your status Blinkenlight (see examples/GenericBlink). Use the BaseFader class if you want fading effects. Here the update method returns an integer 0..255.

  • Subclass the BaseBlinker class with custom logic. This is what Blinkenlight does internally (see src/Blinkenlight.h). Have a look at the SerialBlink example!

Why

I created this library because I like to blink my error codes to the user. So for example blink two times, then three times for error 23 - you get the idea.

Over the time I found it super useful to handle basically all buzzers, lights and LEDs. I have multiple applications where it controls status lights via CAN.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].