Skip to content

Instantly share code, notes, and snippets.

@jasoncoon
Created April 7, 2017 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasoncoon/1485c25fdd0b36ca7fcb3586af305f87 to your computer and use it in GitHub Desktop.
Save jasoncoon/1485c25fdd0b36ca7fcb3586af305f87 to your computer and use it in GitHub Desktop.
FastLED HSV Dials - Example project showing how to use Hue, Saturation, and Value to create color.
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 12
#define DATA_PIN 0
#define HUE_PIN A4
#define SAT_PIN A5
#define VAL_PIN A6
// Define the array of leds
CRGB leds[NUM_LEDS];
byte hue = 0;
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(64);
}
void loop() {
int value = 0;
value = analogRead(HUE_PIN); // read the value from the potentiometer
byte hue = map(value, 0, 1023, 0, 255); // scale value from 0-1023 to 0-255
value = analogRead(SAT_PIN); // read the value from the potentiometer
byte sat = map(value, 0, 1023, 0, 255); // scale value from 0-1023 to 0-255
value = analogRead(VAL_PIN); // read the value from the potentiometer
byte val = map(value, 0, 1023, 0, 255); // scale value from 0-1023 to 0-255
CHSV color = CHSV(hue, sat, val);
fill_solid(leds, NUM_LEDS, color);
FastLED.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment