Skip to content

RichardLangner/BlinkDigits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

'BlinkDigits' by Richard Langner

Bink out numbers on a single LED.

Display any number from 0 to 99999. For example 390 is blinked as

  • 3 brief flashes,
  • 9 brief flashes,
  • 0 (one long flash).

    After each digit there is a brief pause before the next digit is flashed.
    When all digits in your number have been flashed, there is a longer pause, and then it all repeats - if you want it to.

How can BlinkDigits improve my project?

  • Use as a heartbeat LED to indicate the status of the program.
  • Indicate an analog reading
  • Indicate a digital counter
  • When connected to wifi, blink out the last 3 digits of the IP address, so you know where to find your device on the network.

How to use FlashDigits

Example :
flasher1.blink ( D4, LOW, 1883 )

  • D4 is the pin number of the LED ( you can use LED_BUILTIN )
  • LOW (or HIGH) is set to define the level required to turn on the LED
  • 1883 is the number you want to blink ( in the range of 0-99999 )

    BlinkDigits returns 'true' when all the digits have been flashed. See examples for why this is useful.

Example code

Here is a simple example which uses one line of code in loop( ) to blink out 23.

#include "BlinkDigits.h"
BlinkDigits flasher1;
int ledPin = D4;

void setup() {
	pinMode(ledPin, OUTPUT);`
}

void loop() {
    flasher1.blink(ledPin, LOW, 23);
}

Leading zeros

If you want to blink out leading zeros, for example 023, simply state the number of places you want - using the optional 'width' parameter - in this case 3.

flasher1.blink(ledPin, LOW, myNumber,3);

Customisation

Blinking too fast for you to read?
Here we slow things right down.
flasher1.config(400,1500,800, 5000); // slower timings.

  •  400 : the on/off digit 'flash' time,
  • 1500 : the zero digit's 'on' time
  •  800 : the delay between digits
  • 5000 : the delay before repeating the number.
  • Defaults are 200, 1000, 500, 3000.

Trouble shooting

  • Eratic timing of blinks : ensure you haven't used blocking code elsewhere in your project. BlinkDigits relies on fast non-blocking code in loop( ).

  • LED not blinking : Ensure you have the correct pin for the LED, and it is defined as output.

  • Not blinking : Ensure the number is between 0 and 99999, and not negative.

  • Wrong number of blinks : do not add your own leading zero in code, as this denotes octal numbers i.e. do not use 023 (it will blink out 19), simply use 23 instead.

  • Not all digits blinked If you included the 'width' parameter, make sure it is set correctly.

About

BlinkDigits

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages