Fade between colors

Hello,

I just learned to use the RGB led on a arduino with this course (https://www.youtube.com/playlist?list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP)

Now I wonder lets say I have red.
Is there a way I can make it work that it fades slowly to lets say blue.

To fade from RED (255, 0, 0) to BLU (0, 255, 0) you should subtract 1 from RED in your first loop to make (0, 0, 0), then add 1 to BLU in your second loop to make (0, 255, 0).

Thanks,

Now I think a difficult one,
From cyan (0, 183, 235) to orange ( 255 , 102, 0) ?

You will do a similar "add here/subtract there"

I would to re-define CYN as (0, 255, 255) and ORG as (255, 127, 0)

  1. Starting with CYN, subtract 1 from GRN and BLU (red, GRN, BLU) until (0, 0, 0)
  2. To get ORG, add 0.5 to RED and 1 to GRN every loop until GRN == 127 (or RED == 255)

When counting by "0.5" with an "int" (the color values from 0 to 255), you will not see "half-steps" in color because "int" is only whole numbers (0, 1, 2, 3, ...). But, when you add 0.5 + 0.5 + 0.5 + 0.5 you "brighten" the LED once every two steps. 0, x, 1, x, 2, x, 3, x...

Start from the easy thing - can you design a code to fade, say, RED led from brightness 255 to brightness 0?

When you finish, you can fade from Color1(255,x,y) to Color2(0,x,y). Repeat this to the Green and Blue - and you can able to fade from and to any combination of colors

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.