Hi All
Thanks for reading. I'm enjoying playing with my neopixel LED strip at a basic level, however I'm having trouble combining some of the great examples into one sketch. New to coding. Apologies.
I.e I'd like to do a colorwipe and some sparkle (one after the other) in the same loop. Or maybe combine 3 example effects into one sketch so that I can run each for a few minutes consecutively in a loop.
Ive attached code below where the sparkle effect doesnt work. I can successfully do multiple colorwipes within the one sketch .
Im sure there are some fundamental coding lessons I need to learn here. At the moment I am just cut/pasting the examples.
Much appreciated.
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_LEDS 90
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
// *** REPLACE FROM HERE ***
void loop() {
colorWipe(0xff,0xff,0xff, 12.9); //1.38 second wipe
setAll(0,0,0); // set all to off for delay between wipes
colorWipe(0xff,0xff,0xff, 129); //13.8 second wipe
delay(13800); // adding 13.8 seconds all on
setAll(0,0,0); // set all to off for delay between wipes
Sparkle(0xff, 0xff, 0xff, 0); //perform sparkle function for 1 minute
delay (3600);
}
void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
int Pixel = random(NUM_LEDS);
setPixel(Pixel,red,green,blue);
showStrip();
delay(SpeedDelay);
setPixel(Pixel,0,0,0);
}
void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
for(uint16_t i=0; i<NUM_LEDS; i++) {
setPixel(i, red, green, blue);
showStrip();
delay(SpeedDelay);
}
}
// *** REPLACE TO HERE ***
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}