Advertisement
masbass

FastLED set Hue/Brightness/Saturation with 3 potentiometers

Aug 8th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3.  
  4. #define NUM_LEDS 1
  5. #define LED_PIN 6
  6.  
  7. #define COLOR_ORDER GRB
  8. #define LED_TYPE WS2812
  9.  
  10. CRGB leds[NUM_LEDS];
  11.  
  12. int poti1 = 0; //brightness @ pin A0
  13. int poti2 = 1; //hue @ pin A1
  14. int poti3 = 2; //saturation @ pin A2
  15.  
  16. int poti1val = 0;
  17. int poti2val = 0;
  18. int poti3val = 0;
  19.  
  20.  
  21. uint8_t brightness = 0;
  22. uint8_t hue = 0;
  23. uint8_t saturation = 0;
  24.  
  25. void setup() {
  26.  
  27. delay(3000); // safeguard delay
  28.  
  29. LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  30.  
  31. }
  32.  
  33. void loop() {
  34. poti1val = analogRead(poti1);
  35. poti2val = analogRead(poti2);
  36. poti3val = analogRead(poti3);
  37.  
  38. brightness = map(poti1val, 0, 1023, 0, 255);
  39. hue = map(poti2val, 0, 1023, 0, 255);
  40. saturation = map(poti3val, 0, 1023, 0, 255);
  41.  
  42.  
  43. for (int i = 0; i < NUM_LEDS; i++) {
  44. leds[i] = CHSV(brightness, hue, saturation);
  45. }
  46. FastLED.show();
  47. delay(10);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement