Created
April 7, 2017 00:54
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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