This is a request placed in the comment of one of the articles.
To keep things clean, I've moved it into the forum.
Original comment: link.
Hello
I really appreciate the amount of work you put into creating this site. it has lots of useful information.
could you please kindly look at my sketch and tell me if you find any issue with it.
it is for running leds from side to center with white color.
I have been told the left side is moving faster than right.I appreciate if you could take a look and tell me how to fix it?
here is my code (cleanup):
#include “FastLED.h”
#define NUM_LEDS 12
#define PIN 7
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds < WS2812, PIN, GRB > (leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
}
// REPLACE FROM HERE
void loop() {
// colorWipe(0x00,0xff,0x00, 50);
// colorWipe(0x00,0x00,0xff, 50);
// colorWipe(0xff,0x00,0x00, 50);
// colorWipe(0x0f,0xff,0x0f, 50);
// colorWipe(0,255,50, 50);
// colorWipe(0xff,0x24,0xf8, 50);
colorWipe(0xe9, 0xff, 0x21, 50);
colorWipe(0, 255, 255, 255);
// colorWipe(0x1f,0x0f,0xff, 50);
// colorWipe(0x12,0xff,0x88, 50);
// colorWipe(0xff,0xff,0xff, 50);
}
void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
for (int i = 0; i < (NUM_LEDS / 2) + 1; i++) {
setPixel(i, red, red, red);
setPixel(NUM_LEDS– i, red, red, red);
showStrip();
delay(150);
}
setAll(0x00, 0x00, 0x00);
}
// 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();
}