Last active
July 17, 2018 13:57
-
-
Save chemdoc77/c50cf72061a454167d3e68856c64e07a to your computer and use it in GitHub Desktop.
Setting different brightness levels in a ring by Chemdoc77
This file contains 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
//Setting different brightness levels in a ring by Chemdoc77 | |
//used to having a group of choosen leds brighter than the rest of the leds in a ring or strip. | |
#include <FastLED.h> | |
#define DATA_PIN 6 | |
#define LED_TYPE NEOPIXEL | |
#define NUM_LEDS 24 | |
CRGB leds[NUM_LEDS]; | |
int brightness = 100; | |
void setup() { | |
delay(1000); | |
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS); | |
FastLED.setDither(false); | |
FastLED.setCorrection(TypicalLEDStrip); | |
FastLED.setBrightness(brightness); | |
FastLED.setMaxPowerInVoltsAndMilliamps(5, 400); | |
set_max_power_indicator_LED(13); | |
fill_solid(leds, NUM_LEDS, CRGB::Black); | |
FastLED.show(); | |
} | |
void loop() { | |
cd77_fill_by_hue_all(0, NUM_LEDS, 8, NUM_LEDS, 60); | |
//first number is the color in hue, second number is the number of leds used, | |
//third number is the first number of the lower brightness leds, fourth number is the upper range of lower brightness leds+1 used, | |
//the last number is lower brightness of leds in lower brightness range leds (0 - 255). | |
//see the discussion of hue colors in FastLED:https://github.com/FastLED/FastLED/wiki/Pixel-reference (middle of webpage) | |
FastLED.delay(1000); | |
fill_solid( leds, NUM_LEDS, CRGB::Black); | |
FastLED.delay(500); | |
} | |
//==================== Functions =============================== | |
void cd77_fill_by_hue_all(uint8_t hue, uint8_t to, uint8_t from2, uint8_t to_2, uint8_t brighness1) { | |
for (uint8_t i = 0; i <to; i++) { | |
leds[i] = CHSV( hue, 255, 255); | |
} | |
for (uint8_t x = from2; x <to_2; x++) { | |
leds[x] = CHSV( hue, 255, brighness1); | |
} | |
FastLED.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment