Using FastLED with Blynk I am struggling to understand how to get Blynk to

Using FastLED with Blynk

I am struggling to understand how to get Blynk to work with one of the FastLED example ColorPalette? What I would like to do is to replace ChangePalettePeriodically(); with Blynk buttons instead so that I can control the mode that it is currently in. I understand how to read the state of my Virtual Pin on my Huzzah Feather by the following:

BLYNK_WRITE(V14)
{
int RandomColorspin = param.asInt(); // assigning value pin V14
if(RandomColorspin == 1) {
SetupTotallyRandomPalette();
currentBlending = LINEARBLEND;
Serial.println(“RandomColorspin Mode ON”);
}
}

I have verified that Blynk is successfully controlling my Arduino Feather using the Serial monitor.

But Blynk warns users not to put anything into the void loop that would cause delay and the current example ColorPalette does this. Could someone help me adopt the ColorPalette example to be operated by Blynk. I think it will probably involve using the BlynkTimer.

My current sketch is here:

https://app.box.com/s/e552tlo1ayfvfoj8cilipbdb3a9x9xf6

Current video of my light project here:

https://app.box.com/s/quo4p9dzg3hll5mk74z5cs4rcbqm4mii

Blynk has a 5 second timeout or thereabouts, you can put a few operations in your loop and get away with it just fine. Did you try it?

Also the Blynk community forums are very helpful. Maybe ask there too?

Hi Matthew, that is exactly the “rub” here; I would like the the transition time between the different palettes to be well beyond 5 second - i.e. maybe a linearblend of 10 to 15 seconds.

I use Blynk and color palettes in all of my projects. I’ll send you an example sometime tomorrow if I remember. Otherwise feel free to message me on Hangouts to remind me

@Mark_Biasotti In that case the trick is to only do a bit of pallette transitioning each loop(). Have a counter that keeps track of how far you are through the transition.

If that doesn’t quite make sense I’ll try and do a proper explanation later…

Replace changePalettePeriodically() with a switch statement and use a variable called ledMode or similar that gets changed to a different value with each button press in the Blynk App. I would personally use a menu in Blynk for the color palettes instead of having a bunch of buttons all over the place but I guess that’s up to you really. The menu returns an index number with each change and starts with the first entry being 1. In the Blynk Virtual Write function for the menu you can use a switch statement and have a case for each palette desired.

Now if you want the option to have the color palette randomly change after x amount of seconds or minutes you can have a button in Blynk that enables “Random Mode” and use an if statement to check if random mode is on or not. You can then use the EVERY_N_SECONDS(n) function to set the palette to a random number.

Hopefully that all makes sense. I can send an example if needed.

@Brian_Lewis

“…I would personally use a menu in Blynk for the color palettes instead of having a bunch of buttons all over the place but I guess that’s up to you really.”

Yeah, I don’t want to use buttons in Blynk, but Blynk does not currently have a “Radio” or “Selector” switch; this is what I’d really like to have instead of button (especially since I have to purposely turn one off before I turn on the other - i.e. Blynk does not have a widget to switch modes… (that I know of.)

@Mark_Biasotti http://docs.blynk.cc/#widgets-interface-menu This is what I use for color palettes and LED modes in all of my projects.

@Mark_Biasotti https://gist.github.com/Blink515/9774dfc962e0967edfc6df7f9289e902

Brian,

Thanks for the Blink Sketch - looks useful for what I”m doing.

Mark

Mark Biasotti
@** <@**>

"Without Me you can do nothing and if you do nothing, it will be without Me.”

Jesus Christ & Dallas Willard

Brian’s suggestions above are all good ones.

Also, I updated my basic Blynk example to include a Menu example.

@Brian_Lewis
Hi Brian,

Can you show me an image of what your Blynk interface setup looks like? - the link you provided is just to a Blynk help doc about interface.

thanks

Mark

@Mark_Biasotti I just updated my Gist to show a basic example of my projects minus the functions for the animations. Should give you a good framework to build off of. This barcode will load the project into Blynk for you. It should anyways, but I use a local Blynk server so it may not load. If it doesn’t work I will post a screenshot of the setup itself.

@Brian_Lewis

Hi Brian, took your sketch and adopted it to my Adafruit Huzzah ESP8266 and driving 9 P9813 LED Strip controls. I know that I have those two working together successfully. I set up my blynk like yours (although interchanged a few of the virtual pin assignmenst and I’m using wifi) and the sketch compiles and uploads but does seem to work. I 've put in some serial monitor debug to see if blynk buttons are working and they are, so not sure what’s the problem? here is my sketch:

https://app.box.com/s/okket3n144nu19oarveh8kgzbvz0qzdk

@Mark_Biasotti I’ll load it up in about 30 minutes and take a look at it.

@Mark_Biasotti1 Hi Mark, I just tested your code and it is working just fine for me. I only have WS2812 and a Wemos D1 mini to test with but it lit up and the animations changed as expected.

One suggestion, unless you are trying to slow the animations down I would remove the EVERY_N_MILLISECONDS(10) portion around the code that checks which animation should be active.

@Brian_Lewis
Hi Brian, I got it to work - when I comment out all the Serial.print stuff? I think the serial monitor is interfering with blynk. So now I know. On to modifying the sketch for what I want to do. I am concern thou that I want very slow transitions (30 sec. 1 min.) on my modes and don’t you think I’ll have to use SimpleTimer or BlynkTimer to do this?

@Mark_Biasotti Very slow transitions between animations or colors? I wouldn’t mess with Blynk’s timers. The FastLED EVERY_N_ timers are efficient and easy to work with.