Created
September 1, 2018 00:04
-
-
Save chemdoc77/ff5dd6a253abe3e5a3d3491b202d072b to your computer and use it in GitHub Desktop.
Mark Kriegsman's Pride2015 for NeoPixels
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
#include "FastLED.h" | |
// Pride2015 | |
// Animated, ever-changing rainbows. | |
// by Mark Kriegsman | |
//https://gist.github.com/kriegsman/964de772d64c502760e5 | |
//Modified for NeoPixels by Chemdoc77 | |
#if FASTLED_VERSION < 3001000 | |
#error "Requires FastLED 3.1 or later; check github for latest code." | |
#endif | |
#define DATA_PIN 6 | |
#define LED_TYPE NEOPIXEL | |
#define NUM_LEDS 64 | |
#define BRIGHTNESS 50 | |
CRGB leds[NUM_LEDS]; | |
void setup() { | |
delay(1000); // 1 second delay for recovery | |
// tell FastLED about the LED strip configuration | |
FastLED.addLeds<LED_TYPE,DATA_PIN>(leds, NUM_LEDS) | |
.setCorrection(TypicalLEDStrip) | |
.setDither(BRIGHTNESS < 255); | |
// set master brightness control | |
FastLED.setBrightness(BRIGHTNESS); | |
FastLED.setMaxPowerInVoltsAndMilliamps(5,1500); | |
set_max_power_indicator_LED(13); | |
fill_solid(leds, NUM_LEDS, CRGB::Black); | |
FastLED.show(); | |
} | |
void loop() | |
{ | |
pride(); | |
FastLED.show(); | |
} | |
// This function draws rainbows with an ever-changing, | |
// widely-varying set of parameters. | |
void pride() | |
{ | |
static uint16_t sPseudotime = 0; | |
static uint16_t sLastMillis = 0; | |
static uint16_t sHue16 = 0; | |
uint8_t sat8 = beatsin88( 87, 220, 250); | |
uint8_t brightdepth = beatsin88( 341, 96, 224); | |
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256)); | |
uint8_t msmultiplier = beatsin88(147, 23, 60); | |
uint16_t hue16 = sHue16;//gHue * 256; | |
uint16_t hueinc16 = beatsin88(113, 1, 3000); | |
uint16_t ms = millis()*2; | |
uint16_t deltams = ms - sLastMillis ; | |
sLastMillis = ms; | |
sPseudotime += deltams * msmultiplier; | |
sHue16 += deltams * beatsin88( 400, 5,9); | |
uint16_t brightnesstheta16 = sPseudotime; | |
for( uint16_t i = 0 ; i < NUM_LEDS; i++) { | |
hue16 += hueinc16; | |
uint8_t hue8 = hue16 / 256; | |
brightnesstheta16 += brightnessthetainc16; | |
uint16_t b16 = sin16( brightnesstheta16 ) + 32768; | |
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536; | |
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536; | |
bri8 += (255 - brightdepth); | |
CRGB newcolor = CHSV( hue8, sat8, bri8); | |
uint16_t pixelnumber = i; | |
pixelnumber = (NUM_LEDS-1) - pixelnumber; | |
nblend( leds[pixelnumber], newcolor, 64); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment