hello. I have recently been messing with FastLED again.

hello.

I have recently been messing with FastLED again.

If I want to limit the colors that CONFETTI shows to just GREEN and BLUE
is there a way to do that in the code. I have tweaked every variable I can and they seem to just adjust brightness, spread, etc…I also tried adjusting the gHue but that didnt seem to change it either.

I am also interested in limiting the JUGGLE and SINEON patterns to just GREEN/BLUE.

I am helping with a water themed costume.

I am running either on TEENSY 3.2 or ARUDINO UNO.

thanks.

Here’s a version of Confetti that does only Green and Blue hues.
https://pastebin.com/kCaiVzMf
Note there is a percentage variable in there too. Put it back to 100 if you want max confetti! :slight_smile:

For Juggle, the variable dothue is the color. It starts out equal to 0 (red), but you could set it start at green. And then also comment out line 123: dothue += 32;
so it won’t change the color as it loops. Then you can make a copy of the whole juggle pattern subroutine and set dothue to blue so you will have both a green and blue version in your pattern mix.

You should be able to do similar for Sinelon. Just add your own “hue” variable and set to hue green or blue. Replace gHue with the “hue” variable.

[I edited the above a bit to hopefully be a bit more clear.]

Use palletknife to select a set of colir variants you like and shift through that pallet. I did that to demoreel100 bpm sample. :slight_smile:

Thanks for the info Marc Miller. I was able to get juggle and confetti to work perfectly. A few questions:
-I can get Sinelon to stay on a specific hue but it seems to randomly skip LEDs. The tail of the streak is not uniform and its odd. Any thoughts?
Also, I want to have a mobile controller and a way for someone to quickly change LED pattern. I have some experience with button inputs but thought it may be easier to just have 4 data pins on the Arduino outputing 4 different patterns (Confetti, Juggle, Sinelon, Rainbow) and have a 4 way switch that could be moved to only feed 1 data line to the strip. I cant seem to get this to code correctly. Any help appreciated !!

Super, glad you got those to work. Post your code to http://gist.github.com with the pattern you’re having trouble with.

If you have four pins always outputting four different patterns all the time, while yes that’s possible, in my opinion that’s wasting a lot of processing power and unnecessary. If you want to use a 4 way switch, instead consider hooking it up to 4 /input/ pins to determine which pattern to run. Or use a button. I’m sure we can get you sorted out.

Here’s a few examples of using a button for changing patterns.

Hey Marc, thanks for the help.
I have a simple 4 button that I will use for this project:

I tried to add code using the Button-Master library (renamed Button) to the Demo Reel. Its very confusing to know where to add the code.
I would simply like to display the first pattern Confetti_GB and if a button 1 is pressed to stay on that pattern. If button 2 is pressed to show Juggle and stay on that pattern. If button 3 is pressed to show Sinelon and if button 4 is pressed, to show rainbow. If button 1 is pushed, show Confetti_GB and wait for more input.
Basically if any button is pushed, to switch to that pattern and stay there. Is this possible?

I know I need to add an if/else statement for each button.

I tried to merge the code and keep running into rainbow not being declared in the scope. What does that really mean??

I have very little coding experience but have occasionally been able to make things hustle along.

A few other questions. Why is the website called Github and what is gist?

Thanks very much.

Yes, that button should work and you can do what you have in mind. I recommend with most projects consisting of multiple parts and also when you’re learning, break things up into small parts where it’s easier to learn and test. Make multiple simple setups (for example, use the FastLED “Blink” example and have each button set a color to blink). Once you learn how to use the buttons and library and confirm how to wire things then move on to integrating it into a larger project. Plus those small examples you build for yourself are super for testing other things out in the future.

Have a look at my DemoReel100_with_button example again. Note where I commented out:
EVERY_N_SECONDS( 10 ) { nextPattern(); }
at line 67, and added my button check in that location.

For your four buttons you’ll need four sets of these lines:

const int buttonPinA = 4; // Set digital pin 4 for button A
Button myButtonA(buttonPinA, true, true, 50);

const int buttonPinB = 5; // Set digital pin 5 for button B
Button myButtonB(buttonPinB, true, true, 50);
etc.

And in my readbutton() function at the bottom of the code you would end up with four checks of reading each button.

void readbutton() {
myButtonA.read();
if(myButtonA.wasPressed()) {
//A was pressed so set a variable or do something
}
myButtonB.read();
if(myButtonB.wasPressed()) {
//B was pressed so set a variable or do something
}
etc.

}

I think of http://gist.github.com (somewhat similar to pastebin) as more for just sharing single files or pieces of code. http://Github.com is more for collecting all the files for whole projects or larger collections of files (can be different file types too).

thank you. I look forward to digging into this

Thanks for the help thus far.
I have added what I believe to be the correct code for 4 buttons. I have not added the 4 lines of code at the bottom to specifically tell strip to show different patterns. I think there is a single line using FastLED to do this…also when I compile my code as it stands now, I get an error stating

"no matching function for call to ‘Button::Button(const int&, bool, bool, int)’ "

Any help greatly appreciated. Here is my current code:

Looks like you’re missing a closing brace } on the readbutton() fuction.

Keep going!

Also, when I try to upload your demoreel w/button code, I keep getting an error stating no matching function for call to ‘Button::Button(const int&, bool, bool, int)’

seems like a library discrepancy, dunno

You downloaded the Button library, unzipped it, renamed it to just Button if needed, put it in the same location as the FastLED library, and closed and restarted Arduino?

yes. I even deleted Arduino program and reinstalled. When I try to compile the basic_usage example from the button library, it compiles. But when I try to compile your demo w/button, it gives me that same error code:

"no matching function for call to ‘Button::Button(const int&, bool, bool, int)’ "

the problem may be that there are 2 button libraries. Master-Button which is supposed to be renamed button and another also named button

Oh yes, multiples of same library can/will be a problem. Delete one so you just have one Button library folder. Hopefully that’s it.

Yup, your code works if I rename Button-master to Button, but the Button library in the arduino Lib. manager is diff. and wont work !

I don’t use that library manager at all. I specifically get the libraries I want and put them in my custom library location (which is on Google drive so my libraries are the same on all my systems/devices).

Hey Marc and community. I have resolved my library issues and have successfully uploaded code to use 1 button to scroll through patterns. I am now attempting to use 4 buttons and not having success. When I call readbutton at the end of my void loop, I need it to reference my read button functions at the end of my code and react to presses. Currently I am just trying to keep it simple and set the strip to a different color, but ultimately I want to have each button set a different pattern. Is there a FastLED command to set a pattern that I can put in my read button functions?

thanks as always
Here is my current code:

On line 31 you’ve set the variable i = 12. But when that gets plugged in down below in the button read area that won’t work since 12 is beyond the number of pixels you’ve defined. You’re on the right track though.