Giter Club home page Giter Club logo

fastled-demos's Introduction

FastLED-Demos

By: Andrew Tuline

Email: [email protected]

Date: May, 2019

**Update: April 2020. I am stopping work on my 'notasound/notamesh' large demos in favour of supporting WLED (at wled.me).

Here's a big pile of FastLED demos.

!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!

Before attempting to use these demos, make sure you can compile and run the examples found with the latest version of the FastLED library.

If this is your first foray into addressable LED's, then start off with a small strip of less than 20 LED's. Long strips require careful power management design and implementation, so start off small and then work up to longer strips.

Spend some time analyzing these demos, make changes to them and then make your own. Don't start off as a beginner trying to compile and run the advanced demos. Build up to it.

Finally, before looking for some support, have a look at fastled_support_faq.txt. Key things are to:

  • Check everything several times.
  • Break it down into simple components.
  • Write small test programs so that you understand concepts.
  • Learn the basics before trying the advanced routines.

Introduction

Here are several display sequences for FastLED for a single strand of addressable RGB LED's, such as NeoPixels/WS2812, WS2801 or DotStars/APA102. Each should compile and run separately and all have been tested on an Arduino Nano with appropriate inputs as required.

Almost all of these sequences are designed to be loop/non-blocking delay friendly. They perform some simple calculations, update the LED array, return back to the loop to SHOW the LED's and then continue on to the next iteration.

In addition to several standalone demos, I have included comprehensive demos called notamesh and notasound (NOT for beginners), which supports multiple display sequences, multiple Arduino's, has a demo mode, EEPROM IR remote and sound reactive support. There are also a couple of separate button controlled demos with EEPROM support.

In addition, I have included a few other sound reactive sequences, most notably fht_log_ripple, which uses the ADMP401 MEMS microphone and the FHT (Fast Hartley Transform) library to respond to sound in the frequency domain. Tricky to get going, but very cool.

Notable Files

black.ino - Turns off your LED's, so you can program in peace without having to unplug your strand.

button_demoReel100 - Use button to control the mode. Press button for > 1 second to save current mode to EEPROM (as startup mode). This required a 3rd party button library.

notamesh.ino - Huge IR controlled demo display. Now works with ESP8266 and NOT for beginners.

Introducing notamesh and notasound

Introducing two new display demos for Arduino and FastLED.

notamesh – Introduces the ability to synchronize and delay display sequences across multiple Arduino microcontrollers via IR control.

Q. What is this ‘mesh’ all about? You can configure multiple Arduino microcontrollers with the same display sequence, but with a short delay, thus giving the effect of synchronization.

Scenario: You have 5 IR controlled Arduino based displays, all within eyesight of each other, and all running notamesh. At compile time, each will be configured for the type of LED’s in use as well as a unique ID for each and with demo mode enabled. Upon first time power-up, each strand will be configured with the length of the strand, as well as a delay. For instance, each Arduino has 40 LED’s connected to it.

  • Arduino A1 – 0ms delay
  • Arduino A2 – 100ms delay
  • Arduino A3 – 200ms delay
  • and so on . . . .

Once they’re all programmed and running, you would then press the ‘Reset’ button on the IR controller in order to synchronize millis() and the Arduinos would begin displaying the demo mode, with each Arduino slightly out of sync with the others.

These sketches:

  • Run on an Arduino UNO/Nano, etc.
  • Use the FastLED display library.
  • Use Nico Hood’s IR library.
  • Include a LOT of display routines.

Basic IR Functionality

  • Adjust overall brightness.
  • Adjust overall speed.
  • Reset (to sync multiple controllers).
  • Enable/disable demo mode.
  • Increase/decrease speed of animation.
  • Adjust overall brightness.
  • Change direction of some routines.
  • Enable/disable glitter.
  • Select previous/next display routine.
  • Enable/disable palette rotation.
  • Select previous/next palette.
  • A 'lamp' mode.
  • Select hue/saturation.
  • Select a single hue based palette

EEPROM Functionality

  • Select specific Arduino for EEPROM configuration.
  • Adjust strand length.
  • Adjust mesh delay.
  • Change startup display mode.
  • Program/select 2 favourite display modes.
  • Added a bunch of other things as documented in notamesh and notasound.

Sound functionality

  • Continuous sampling of sounds via ADMP401 microphone.
  • Averaging of last 32 samples.
  • Quick averaging of last 4 samples.
  • Crude peak detection.
  • Integration of sound with various display routines.
  • IR control of sound squelch.
  • No FFT or MSGEQ7 required.

My FastLED Animation Philosophy

  • Do NOT use delay statements in the loop as that breaks input routines (i.e. button).
  • Do not use nested loops (for performance reasons).
  • Use millis() as a real time counter unless a fixed counter is required.
  • Spend a bit more time using high school math (ie trigonometry), rather than just count pixels.
  • Keep the display routines as short as possible.
  • Data typing as strict as possible i.e. why define an int when a uint8_t is all that is required. Oh, and floats are not used at all.
  • Localize variables to each routine as much as possible.
  • Break out the display routines into separate .h files for increased readability and modularity.
  • Be generous with comments.

Controls

  • TSOP38238 IR receiver and a 24 button IR controller for IR control.

More

Information about the awesome FastLED Library is available from: fastled.io

Download FastLED from: github.com/FastLED/FastLED

FastLED Documentation is at: http://fastled.io/docs/3.1/modules.html

The FastLED community is at https://www.reddit.com/r/fastled


My Youtube channel is at: https://www.youtube.com/user/atuline/videos My Github account is at: https://github.com/atuline My Gists are at: https://gist.github.com/atuline My Pastebins are at: https://pastebin.com/u/atuline FastLED support forum: https://www.reddit.com/r/fastled

fastled-demos's People

Contributors

atuline avatar davidbrai avatar lpmi-13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastled-demos's Issues

inoise8_fire.ino is not compiling.

inoise8_fire.ino is not compiling,

Arduino: 1.8.9 (Windows 10), Board: "LOLIN(WEMOS) D1 mini Pro, 160 MHz, Flash, Disabled, 16M (15M SPIFFS), v2 Higher Bandwidth, Disabled, None, Only Sketch, 921600"

                 ^

sketch_apr04a:24:9: error: 'uint8_t index' redeclared as different kind of symbol

uint8_t index = 0;

     ^

In file included from C:\Users\HP\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/libc/xtensa-lx106-elf/include/stdlib.h:11:0,

             from C:\Users\HP\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:27,

             from C:\Users\HP\AppData\Local\Temp\arduino_build_526611\sketch\sketch_apr04a.ino.cpp:1:

C:\Users\HP\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/libc/xtensa-lx106-elf/include/string.h:54:15: error: previous declaration of 'char* index(const char*, int)'

char *_EXFUN(index,(const char *, int));

           ^

C:\Users\HP\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/libc/xtensa-lx106-elf/include/_ansi.h:65:30: note: in definition of macro '_EXFUN'

#define _EXFUN(name, proto) name proto

                          ^

C:\Users\HP\Documents\Arduino\sketch_apr04a\sketch_apr04a.ino: In function 'void inoise8_fire()':

sketch_apr04a:61:11: error: assignment of function 'char* index(const char*, int)'

 index = inoise8(i*xscale,millis()*yscale*NUM_LEDS/255);                                           // X location is constant, but we move along the Y at the rate of millis()

       ^

sketch_apr04a:61:11: error: cannot convert 'uint8_t {aka unsigned char}' to 'char*(const char*, int)' in assignment

sketch_apr04a:62:60: error: invalid operands of types 'int' and 'char*(const char*, int)' to binary 'operator*'

 leds[i] = ColorFromPalette(currentPalette, min(i*(index)>>6, 255), i*255/NUM_LEDS, LINEARBLEND);  // With that value, look up the 8 bit colour palette value and assign it to the current LED.

                                                        ^

Using library FastLED at version 3.2.6 in folder: C:\Users\HP\Documents\Arduino\libraries\FastLED
exit status 1
'uint8_t index' redeclared as different kind of sym

bol

pop

I think, that is not a perfect logic:
if (ranamount >NUM_LEDS) ranamount = NUM_LEDS; // Make sure we're at least utilizing ALL the LED's.
int idex = random16(0, ranamount);

if (idex < NUM_LEDS) {        

I have 180 LEDs. If ranamount is set to 50, I will see only a portion.
From my perspective the idea of the parameter ranamount got a bit lost.

if you want idex < NUM_LEDS, why did´nt you call int idex = random16(0, ranamount -1);
or if the idea of ranamount got lost: int idex = random16(0, NUM_LEDS -1);

How to Add More Effects in program

thank you sir,
i Familiar with C and C++ coding. i don't know how how to modify arduino program. Actually i am confused that in which software arduino program can be modified AVR Studio or Arduino IDE.
i want to add more effects of ws2811 led strip.
i see aalight.ino prgoram and i want to add more effects.

Easing Demo doesn't work correctly with higher count of LEDs

The easing demo works fine with the pre-set number of 60 LEDs, but when you raise that number (200 for example) the easing / lerping cause the lerpVal to skip numbers and thus not all of the LEDs will light.

Example output of lerpVal when using 200 LEDs with a 10ms delay:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 3 3 3 3 3 5 5 5 5 5 7 7 7
Which obviously results in LED 1,4,6 not lighting.

This is a very useful demo for beginners, but you run into this issue as soon as you change the number of LEDs to a high enough value or lower the delay. I think it could be worth while to explain how to solve this problem.

irtest - which controller did you use?

Hi,

I was looking around and i saw the more ppl had the same issue as i - Arduino interrupts are collided with the IR remote - did you used teensy here? or you has a successful run with Arduino?

Adding two libraries

Please tell me.
Can we merge a program of fast led and adafruit neo pixal in one single program. I try but lost of errors occur. sir can u give me any example.

Separate channels

How can this be modified so that the bands of color can be broken out to separate pins in order to create a color organ?

Compiling issues

I'm fairly new to programming, I have run through almost all of your demos to help me understand how to program LEDS, and I have gotten almost all of your other demos to work. But with this demo I am having compiling errors. Any ideas how I can fix this? Sorry I'm very new to programming, but it's something that I'd like to try and I like working with LEDS cause they are fun!

having problem to run two effect in one single program

hello, sir i am trying your examples but having trouble to add two example in one program
i am giving example please check and solve my problem.

/* easing
*

  • By: Andrew Tuline
  • Date: August, 2015
  • This boring display demonstrates the easing capability of FastLED. The Red LED starts out slow, speeds up and then slows down when it gets to the end.
  • It uses uint8_t variables:
  • easeOutVal = ease8InOutQuad(easeInVal); // Start with easeInVal at 0 and then go to 255 for the full easing.
  • ledNum = lerp8by8(0, NUM_LEDS, easeOutVal); // Map it to the number of LED's you have.
  • Reference:
  • https://github.com/FastLED/FastLED/wiki/High-performance-math
  • Ideas:
    • Ease from 128 to 255 to throw something in the air
    • Ease from 255 to 128 and reverse direction for it to fall back.
    • Reduce the lerp8 value after each cycle to simulate a bouncing ball.

*/

#include "FastLED.h" // FastLED library. Please use the latest development version.

#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif

// Fixed definitions cannot change on the fly.
#define LED_DT 6 // Data pin to connect to the strip.
#define LED_CK 11 // Clock pin for WS2801 or APA102.
#define COLOR_ORDER RGB // It's GRB for WS2812 and BGR for APA102.
#define LED_TYPE WS2811 // Using APA102, WS2812, WS2801. Don't forget to change LEDS.addLeds.
#define NUM_LEDS 100 // Number of LED's.

// Global variables can be changed on the fly.
uint8_t max_bright = 128; // Overall brightness definition. It can be changed on the fly.

struct CRGB leds[NUM_LEDS]; // Initialize our LED array.

int thisdelay = 10;

//---------------------------------------------------------------

uint8_t hue; // Pixel color
uint8_t offset; // To keep track of the offset in the pattern
uint16_t i; // A pixel position on the strip

// How often does the pattern repeat? Change as needed.
static uint16_t repeatEvery = 5;

// Therefore the number of times the pattern will repeat down the strip is:
static uint16_t numberOfRepeats = NUM_LEDS/repeatEvery;

//---------------------------------------------------------------

void setup() {

delay(1000); // Power-up safety delay.
//LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2801 or APA102
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812

FastLED.setBrightness(max_bright);
set_max_power_in_volts_and_milliamps(5, 500); // FastLED Power management set at 5V, 500mA.

} // setup()

void loop() {

EVERY_N_MILLISECONDS(thisdelay) { // FastLED based non-blocking delay to update/display the sequence.
ease();
}

FastLED.show();
repeating_pattern();
} // loop()

void ease() {

static uint8_t easeOutVal = 0;
static uint8_t easeInVal = 0;
static uint8_t lerpVal = 0;

easeOutVal = ease8InOutQuad(easeInVal); // Start with easeInVal at 0 and then go to 255 for the full easing.
easeInVal++;

lerpVal = lerp8by8(0, NUM_LEDS, easeOutVal); // Map it to the number of LED's you have.

leds[lerpVal] = CRGB::Red;
fadeToBlackBy(leds, NUM_LEDS, 16); // 8 bit, 1 = slow fade, 255 = fast fade

} // ease()

void repeating_pattern()
{for (offset = 0; offset < repeatEvery; offset++) { // Operate on each repeating pixel set
hue = (255/repeatEvery) * offset; // Change the hue for each pixel set.
for (uint16_t x = 0; x < numberOfRepeats+1; x++) {
i = (repeatEvery*(x-1)) + repeatEvery + offset; // The pixel number to draw
if (i < NUM_LEDS) { // Only draw pixel numbers within NUM_LEDS
leds[i] = CHSV(hue,180,255);

    FastLED.show();  // Display each pixel individually in a set
    delay(70);
  }
} //end of loop for pixel set

delay(800);  // Pause before lighting next pixel set

} //end offset loop

delay(1000); // pause before clearing
FastLED.clear(); // clear the strip
FastLED.delay(100); // pause before starting over
}

only one example is running (repeating patterns)
this is happening in most of your examples please help me.

HSB to white

Thanks for this all-in-one FastLED collection (I mean "seirlight" pack). It's realy cool.
I've changed the code to use it in openhab through MQTT protocol. All the modes works great!!
Solid color picker works too, but I have a problem whith solid white color.
"Mode 1" sets it perfect, but when I use HSB Values it never go to white and stays in previously selected hue even when brightness goes to 100 and saturation goes to 0.
In other words I can't set the lightly green color (for example), just standart green wich can be dimmed only by brighness trigger.

flicker

if you move the show call into EVERY_N call
output get much more smooth.
I guess that the high refresh rate of leds causes the flicker.

And as long you do not change the LEDs there is no need for a show call.

results in:

void loop () {
EVERY_N_MILLISECONDS(thisdelay) { // FastLED based non-blocking delay to update/display the sequence.
ripple();
show_at_max_brightness_for_power();
}

} // loop()

Want to make class program

Please help me.
i want to write this code as a "class" type (class example is below). I want to add this code with other class examples.

void loop() {
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color(0, 0, 127), 50); // Blue
}
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();

  delay(wait);

  for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
    strip.setPixelColor(i+q, 0);        //turn every third pixel off
  }
}

}
}

like this class example
class colorWipe: public animation {
public:
colorWipe(void) { w = random(256); }
virtual void init(void);
virtual void show(void);
private:
byte w;
int index;
bool fwd;
};

void colorWipe::init(void) {
int p = random(2, 4);
w += p*16 + 1;
fwd = random(2);
index = 0;
if (!fwd) index = strip.numPixels() - 1;
}

void colorWipe::show(void) {
uint32_t color = Wheel(w);
if (fwd) {
if (index > int(strip.numPixels())) { // Start new sequence with the new color
init();
complete = true;
return;
}
strip.setPixelColor(index++, color);
} else {
if (index < 0) { // Start new sequence with the new color
init();
complete = true;
return;
}
strip.setPixelColor(index--, color);
}
complete = false;
}

Lightnings non blocking

I cannot seem to get this animation to run using millis() instead of delays. Obviously a beginner.

i want to run normal program with class type of program

NEED HELP
Can i run "class" code with normal example code.
i try but only one of them is running. what should i do please tell me.

class example
class colorWipe: public animation {
public:
colorWipe(void) { w = random(256); }
virtual void init(void);
virtual void show(void);
private:
byte w;
int index;
bool fwd;
};

void colorWipe::init(void) {
int p = random(2, 4);
w += p*16 + 1;
fwd = random(2);
index = 0;
if (!fwd) index = strip.numPixels() - 1;
}

void colorWipe::show(void) {
uint32_t color = Wheel(w);
if (fwd) {
if (index > int(strip.numPixels())) { // Start new sequence with the new color
init();
complete = true;
return;
}
strip.setPixelColor(index++, color);
} else {
if (index < 0) { // Start new sequence with the new color
init();
complete = true;
return;
}
strip.setPixelColor(index--, color);
}
complete = false;
}

Normal example
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();

  delay(wait);

  for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
    strip.setPixelColor(i+q, 0);        //turn every third pixel off
  }
}

}
}

only mgr.show is running in this loop
void loop() {
mgr.show();
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color(0, 0, 127), 50); // Blue
}
what should i do please tell me.

Slow FPS

Hi Andrew,
Firstly great work on these effects.
This is more of a question so here it is.

I am using your soundmems code in a project of mine and its working flawlessly on a small strip of leds 40 ws2812s (Code is on a esp8266) I get a steady FPS of 400 with this config, When i increase the LED count to 680 I get a low FPS around 10 or so and the animations dont work as they should, Is this very low FPS expected when running so many LED's?

Regards
Trevor

Multiple Strips

I've gotten this to work well enough on a single strip; however, I have 4 led strips in my room, one on each border wall of the ceiling. I tried adding all strips to a single LED array, but for some reason that didn't work.

Is there any way to make multiple strips on multiple pins work?

How do I save the jsbutton as an h file?

When i try to save the JSbutton it opens and saves as a .ino file and not as a .h file, so the button demo reel doesn't compile because there is no such directory. I have tried Save As and type .h after regular address

Auto Mode Cycle

hello sir,
I need a Function to run all the effects one by one. Like auto mode cycle function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.