Using fade on a virtual button

Hi and hello everybody,

Im new in the community and learning to programm stuff. Now I’m a little stuck in my project. I am trying to create a function with a virtualbutton in which by just pressing it the led starts to fade red (Pressing V1) or blue (V2) or green (V3). The thing is that i still cant figure out how to implement the function in void loop given that BLYNK_WRITE hast to be outside of it.

BTW im using a spark core (not particle, the old ones :smile:) just in case this changes anything!

Thanks in advance for any help!!

void fade(){
//fading function
}

BLYNK_WRITE(V1){
   if (param.asInt()) {
   fade();
   }
}

You can take a look at this example:

Hello Pavel and thank you for your quick response :smile:

I already reached that point my problem is to create a way so that by pressing the button (switch) the fade keeps going. So what i need is a timer or some kind of way to insert it into the void loop() so it keeps running. As I said before im using the spark core not an arduino and didn’t found a library to help me to set some kind of timer.

There are a couple of them. I’m using smth called sparkcorepolltimer. Not near the laptop now. Just search for poll timer smth.

Maybe this topic is already dead, but I want the same thing, only with a WeMos D1 with the timer Widget.
I already tries with millis, also with an led fader library, but this was AVR device only… Not esp8266 (WeMos D1).
I am not familiar with SimpleTimer.