How's it going everybody, first post here, I'll dive right in...
I'm using:
Uno R3 - from usb
Neopixel strip - 20 pixels - from a 5v 700ma wall source
and I'm trying to get them to fade through the rainbow while pulsing in brightness. I managed to achieve this by cobbling together some found/example code, but now I'm running into an issue with the strip flickering while doing the pulse. Here's my code thus far:
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, PIN, NEO_GRB + NEO_KHZ800);
int fadeControl = 255;//will hold the current brightness level
int fadeDirection = -1;//change sign to fade up or down
int fadeStep = 20;//delay between updates
void setup() {
strip.begin();
strip.show();
}
void loop() {
rainbowpulse(50);
}
void rainbowpulse(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
strip.setBrightness(fadeControl);//set the pixel brightness
strip.show();
fadeControl = fadeControl + fadeDirection;//increment the brightness value
if (fadeControl <0 || fadeControl > 255)
//If the brightness value has gone past its limits...
{
fadeDirection = fadeDirection * -1;//change the direction...
fadeControl = fadeControl + fadeDirection;//...and start back.
}
delay(fadeStep);//wait a bit before doing it again.
}
}
}
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
and here's a link to a video of what's happening(it's like 2 minutes long but you can get the point in the first 30sec or so):
Anyone have any ideas on how I could achieve this without this flicker?