Virtual Pins function loop/stop and RGB Strip fade effects

No need for timer2 (which isn’t even running in the last code)

Each timer can have 16 instances and is more efficient than multiple separate timers, especially for such small use.

1 Like

Right, sorry! It works! One last thing would be creating patterns. Like this one:

What parameters should I modify?I can’t wrap my head around the formulas used in the code

Thanks a lot to everyone for taking your time to help

Yes one timer is enough.

What patterns? The video only showed the sliders moving.

But on the note of patterns… you seem to be using a basic RGB strip, but most “patterns” are made with NeoPixel strips, wherein each and every single RGB LED on the strip can be addressed and controlled independently via a single data line. Thus it requires totally different wiring and coding.

1 Like

@Gunner well, yes,I’m showing the sliders moving in a pattern. Wehn red=100%, green goes from 0 to 100%, when green reaches 100%, red goes from 100-0%, when red=0% and green=100%, blue goes from 0 to 100% etc. That’s what I’m trying to do. Yes, I’m using a basic rgb strip with a common anode.

void rgb(){
  for(redVal=1023; redVal<1024; redVal++){
      analogWrite(red, redVal);
      delay(10);
    }
       for(greenVal=0; greenVal<1024; greenVal++){
      analogWrite(green, greenVal);
      delay(10);
       }
       for(redVal=1023; redVal>=0; redVal--){
      analogWrite(red, redVal);
      delay(10);
       }
       for(blueVal=0; blueVal<1024; blueVal++){
      analogWrite(blue, blueVal);
      delay(10);
       }
       for(greenVal=1023; greenVal>=0; greenVal--){
      analogWrite(green, greenVal);
      delay(10);
       }
       for(redVal=0; redVal<1024; redVal++){
      analogWrite(red, redVal);
      delay(10);
       }
       for(blueVal=1023; blueVal>=0; blueVal--){
      analogWrite(blue, blueVal);
      delay(10);
       }
}

This is the function that does exactly what I was showing with the sliders

//To be more specific of what I’m trying to achieve:

@Gunner
I used my application to add the function led for @dragos :joy::joy:.
I already use more than 16 timers, that’s why I used timer2.
I understand that it is confusing I should have corrected my code before posting.
:see_no_evil::see_no_evil::see_no_evil:

1 Like

Found a chart that will help you understand better. I’m looking to get the “Regulas HSV” pattern. Currently I’m running a variation of the “Sine wave” pattern, using @Blynk_Coeur’s code

2 Likes

Bare with me. I’m working on it as I need the code for fading too. As soon as I work it out I’ll post it here :slight_smile:

2 Likes

Just remembered about this after seeing your username in another topic, I made a library that should make it easy for you to do what you require now…

Would it be possible for you to share this variation of the code?
I’m trying to build something similar with the patterns you described… By any chance have you managed to get some progress on that?

I would really appreciate any help you can provide!

1 Like