How can I control led colors with a potentiometer?

How can I control led colors with a potentiometer?

using switch case and pot value

map pot range (0 to 1023) to HSV range (0 to 255) and apply that to an HSV value of one or more LED’s.

Do i have to #include any other H file than the Fastled.H file

I like to get the pot value, and scale it down to 0…255 (hue range). Since analogRead returns 0…1023, just divide by four:

int pot = analogRead( POT_PIN_NUMBER );
uint8_t hue = pot / 4;
CHSV color = CHSV( hue, 255, 255);

Then use ‘color’ for whatever you like.

int pot = analogRead( POT_PIN_NUMBER );
uint8_t hue = pot / 4;
CHSV color = CHSV( hue, 255, 255);<<
Do I place this code in the void setup? Mark Kriegsman

I think you want to read the pot over and over again. So no, not in setup. In loop.

Thanks can i have an example of how my void setup should look

I’d just copy it from any of the FastLED examples , with changes for PIN number and led type.

Alright much appreciated one last thing Mark
where after this code >>> int pot = analogRead( POT_PIN_NUMBER );
uint8_t hue = pot / 4;
CHSV color = CHSV( hue, 255, 255);<< Would I set the color?

Well, after that, you might want to set the whole led array to that one color:

fill_solid( leds, NUM_LEDS, color);

And then show that on the actual LEDs:

FastLED.show();

Those two lines should be inside loop, after the lines above. Good luck, and let us know what you’re able to put together! Try some of the other examples to get the hang of it!

And if you DO get the hang of it, your life may not be the same for the next 2 years.