Hi Guys!
I have a Neopixel ring with my arduino and I want to cycle different color effects in one loop {}.
The lightning 2 effects should be:
- one leds after another should go on red (it should start in the middle of the Neopixel ring and cycle in both direction till the ring is full)and then in the reverse direction it should light blue
This effect works without problems.
- the second lightning effect should be a normal rainbow cycle
BUT after the first lightning effect my arduino stops and the rainbow cycle never comes up.
Maybe someone of you can see my fault in the program code:
#include <Adafruit_NeoPixel.h>
#define RINGPIN 6
uint8_t NUMPIXELS = 24; // total number of LED's in the ring display
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, RINGPIN, NEO_GRB + NEO_KHZ800); // an instance for the LED ring display
void setup() {
// put your setup code here, to run once:
strip.begin();
Serial.begin(9600);
}
void loop() {
//Ascend strip
for (int i = NUMPIXELS / 2; i >= 0; i--) {
//for (int i = 0; i < (NUMPIXELS / 2) + 1; i++) {
strip.setPixelColor(i, strip.Color(255, 0, 0));
strip.setPixelColor(NUMPIXELS - i, strip.Color(255, 0, 0));
strip.show();
delay(50);
}
// Descend Strip
for (int i = 0 ; i >= 0; i++) {
//for (int i = 0; i < (NUMPIXELS / 2) + 1; i++) {
strip.setPixelColor(i, strip.Color(0, 0, 255));
strip.setPixelColor(NUMPIXELS - i, strip.Color(0, 0, 255));
strip.show();
delay(50);
}
rainbowCycle(20);
}
void rainbowCycle(int SpeedDelay)
{
byte *c;
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< NUMPIXELS; i++) {
c=Wheel(((i * 256 / NUMPIXELS) + j) & 255);
strip.setPixelColor(i, *c, *(c+1), *(c+2));
}
strip.show();
delay(SpeedDelay);
}
}
byte * Wheel(byte WheelPos) {
static byte c[3];
if(WheelPos < 85) {
c[0]=WheelPos * 3;
c[1]=255 - WheelPos * 3;
c[2]=0;
} else if(WheelPos < 170) {
WheelPos -= 85;
c[0]=255 - WheelPos * 3;
c[1]=0;
c[2]=WheelPos * 3;
} else {
WheelPos -= 170;
c[0]=0;
c[1]=WheelPos * 3;
c[2]=255 - WheelPos * 3;
}
return c;
}
Many thanks in advance!
Greetings Julian
Moderator note : table tags changed to code tags - OP please use them in future