Created
April 7, 2017 00:55
-
-
Save jasoncoon/a8aa39cb9af44d64b84b801c26073d34 to your computer and use it in GitHub Desktop.
FastLED RGB Dials - Example project showing how to use Red, Green, and Blue 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 8 | |
#define DATA_PIN 0 | |
#define RED_PIN A7 | |
#define GREEN_PIN A8 | |
#define BLUE_PIN A9 | |
// 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 = analogRead(RED_PIN); // read the value from the potentiometer | |
byte red = value / 4; // scale value from 0-1024 to 0-255 | |
value = analogRead(GREEN_PIN); // read the value from the potentiometer | |
byte green = value / 4; // scale value from 0-1024 to 0-255 | |
value = analogRead(BLUE_PIN); // read the value from the potentiometer | |
byte blue = value / 4; // scale value from 0-1024 to 0-255 | |
CRGB color = CRGB(red, green, blue); | |
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