This is a large 14″ 7 segment display that I made in a Marquee style using ws2812B programable leds and ping pong balls as diffusers.
Laserbox Pro – CO2 laser Cutter
//Counter. white digits with fade
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 14
#define BRIGHTNESS 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGBArray<NUM_LEDS> leds;
#define UPDATES_PER_SECOND 1
CRGB alternateColor = CRGB::Black;
short digitPattern[] = {
0b11111111111100, // 0
0b11000000001100, // 1
0b00111100111111, // 2
0b11110000111111, // 3
0b11000011001111, // 4
0b11110011110011, // 5
0b11111111110011, // 6
0b11000000111100, // 7
0b11111111111111, // 8
0b11110011111111, // 9
0b00000000000000, //
0b11001111111111, // A
0b11111111000011, // b
0b00111111110000, // C
0b11111100001111, // d
0b00111111110011, // E
0b00001111110011, // F
0b11110011111111, // g
0b11001111000011, // h
0b00001111000000, // I
0b11110000001100, // J
};
void setup() {
delay( 3000 );
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}
void loop()
{
clearLeds();
delay(800);
for(byte count = 0; count < 21 ; count++) {
displayDigit(count, CRGB::White );
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
delay(100);
FadeLeds();
}
}
void FadeLeds() {
for(byte count3 = 0; count3 < 255 ; count3++) {
leds.fadeToBlackBy(1);
FastLED.show();
delay(1);
}
}
void displayDigit(byte number, CRGB color) {
for (byte i=0; i<14; i++){
leds[i] = ((digitPattern[number] & 1 << i) == 1 << i) ? color : alternateColor;
}
}
void clearLeds() {
for (int i=0; i<NUM_LEDS; i++) {
leds[i] = CRGB::Black;
}
FastLED.show();
}
// Counter with color chase and fade.
//
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 14
#define BRIGHTNESS 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGBArray<NUM_LEDS> leds;
uint8_t colorIndex = 0;
#define UPDATES_PER_SECOND 1
CRGB alternateColor = CRGB::Black;
short digitPattern[] = {
0b11111111111100, // 0
0b11000000001100, // 1
0b00111100111111, // 2
0b11110000111111, // 3
0b11000011001111, // 4
0b11110011110011, // 5
0b11111111110011, // 6
0b11000000111100, // 7
0b11111111111111, // 8
0b11110011111111, // 9
0b11001111111111, // A
0b11111111000011, // b
0b00111111110000, // C
0b11111100001111, // d
0b00111111110011, // E
0b00001111110011, // F
0b11110011111111, // g
0b11001111000011, // h
0b00001111000000, // I
0b11110000001100, // J
0b00000000000000, //
};
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
delay( 3000 );
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
}
void loop()
{
clearLeds();
delay(800);
colorIndex += 0;
for(byte count = 0; count < 21 ; count++) {
displayColorDigit(count, ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending) );
FastLED.show();
for(byte count4 = 0; count4 < 3 ; count4++) {
ColorChaseDigit();
}
delay(500);
FadeLeds();
}
}
void FadeLeds() {
for(byte count3 = 0; count3 < 255 ; count3++) {
leds.fadeToBlackBy(1);
FastLED.show();
delay(1);
}
}
void displayColorDigit(byte number, CRGB color) {
for (byte i=0; i<14; i++){
if ((digitPattern[number] & 1 << i) == 1 << i) {
leds[i]=ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending);
colorIndex += 5;
} else {
leds[i]=alternateColor;
}
}
}
void ColorChaseDigit() {
for (byte i=0; i<14; i++){
if (leds[i]) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending);
FastLED.show();
delay(80);
colorIndex += 10;
}
else {
}
}
colorIndex += 10;
}
void clearLeds() {
for (int i=0; i<NUM_LEDS; i++) {
leds[i] = CRGB::Black;
}
FastLED.show();
}
// Counter with rainbow color segments
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 14
#define BRIGHTNESS 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 1
CRGB alternateColor = CRGB::Black;
short digitPattern[] = {
0b11111111111100, // 0
0b11000000001100, // 1
0b00111100111111, // 2
0b11110000111111, // 3
0b11000011001111, // 4
0b11110011110011, // 5
0b11111111110011, // 6
0b11000000111100, // 7
0b11111111111111, // 8
0b11110011111111, // 9
0b00000000000000, //
0b11001111111111, // A
0b11111111000011, // b
0b00111111110000, // C
0b11111100001111, // d
0b00111111110011, // E
0b00001111110011, // F
0b11110011111111, // g
0b11001111000011, // h
0b00001111000000, // I
0b11110000001100, // J
};
CRGBPalette16 currentPalette;
TBlendType currentBlending;
uint8_t colorIndex = 0;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
delay( 3000 );
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
}
void loop()
{
clearLeds();
delay(800);
for(byte count = 0; count < 21 ; count++) {
displayDigit(count );
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
delay(100);
}
}
void displayDigit(byte number) {
for (byte i=0; i<14; i++){
leds[i] = ((digitPattern[number] & 1 << i) == 1 << i) ? ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending) : alternateColor;
colorIndex += 4;
}
}
void clearLeds() {
for (int i=0; i<NUM_LEDS; i++) {
leds[i] = CRGB::Black;
}
FastLED.show();
}
//Multiple color digits with fade
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 14
#define BRIGHTNESS 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGBArray<NUM_LEDS> leds;
#define UPDATES_PER_SECOND 1
CRGB alternateColor = CRGB::Black;
short digitPattern[] = {
0b11111111111100, // 0
0b11000000001100, // 1
0b00111100111111, // 2
0b11110000111111, // 3
0b11000011001111, // 4
0b11110011110011, // 5
0b11111111110011, // 6
0b11000000111100, // 7
0b11111111111111, // 8
0b11110011111111, // 9
0b00000000000000, //
0b11001111111111, // A
0b11111111000011, // b
0b00111111110000, // C
0b11111100001111, // d
0b00111111110011, // E
0b00001111110011, // F
0b11110011111111, // g
0b11001111000011, // h
0b00001111000000, // I
0b11110000001100, // J
};
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
delay( 3000 );
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
}
void loop()
{
uint8_t colorIndex = 0;
clearLeds();
delay(800);
for(byte count = 0; count < 21 ; count++) {
displayDigit(count, ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending) );
colorIndex += 50;
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
delay(100);
FadeLeds();
}
}
void FadeLeds() {
for(byte count3 = 0; count3 < 255 ; count3++) {
leds.fadeToBlackBy(1);
FastLED.show();
delay(1);
}
}
void displayDigit(byte number, CRGB color) {
for (byte i=0; i<14; i++){
leds[i] = ((digitPattern[number] & 1 << i) == 1 << i) ? color : alternateColor;
}
}
void clearLeds() {
for (int i=0; i<NUM_LEDS; i++) {
leds[i] = CRGB::Black;
}
FastLED.show();
}