Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define NUM_LEDS 56
- #define LED_PIN 2
- #define potPin A1
- int i;
- uint8_t hue = 0;
- uint8_t paletteIndex = 0;
- CRGB leds[NUM_LEDS];
- // Gradient palette "bhw1_05_gp", originally from
- // http://soliton.vm.bytemark.co.uk/pub/cpt-city/bhw/bhw1/tn/bhw1_05.png.index.html
- // converted for FastLED with gammas (2.6, 2.2, 2.5)
- // Size: 8 bytes of program space.
- DEFINE_GRADIENT_PALETTE( bhw1_05_gp ) {
- 0, 1,221, 53,
- 255, 73, 3,178};
- CRGBPalette16 myPal = bhw1_05_gp; // stopt gradient in een palette
- void setup() {
- Serial.begin(9600);
- FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
- FastLED.setBrightness(50);
- }
- void loop() { // deze code laat willekeurige leds aangaan in een willekeurige kleur binnen het palette, en ze daarna langzaam uit faden. De potmeter bepaald hoe snel leds aanspringen, dit wordt alleen bepaald bij opstarten.
- int potRead = analogRead(potPin);
- int potVal = map(potRead, 0, 1023, 0, 200);
- Serial.println(potVal);
- EVERY_N_MILLISECONDS(potRead) {
- leds[random8(0, NUM_LEDS - 1)] = ColorFromPalette(myPal, random8(), 255, LINEARBLEND);
- }
- EVERY_N_MILLISECONDS(50) {
- blur1d(leds, NUM_LEDS, 100);
- }
- FastLED.setBrightness(potVal);
- FastLED.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement