ColorWipeFromCenter 32 LED strip Example

What about a color chase from the center while running it over a base color?
ColorChaseFromCenter 32 LED strip Example

Thanks,
Phil
Moderators: adafruit_support_bill, adafruit


int i;
uint32_t c;
// Set all pixels to red
c = Color(255, 0, 0);
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
delay(100);
// Wipe from middle:
c = Color(255, 255, 255); // white
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.show();
delay(100);
}#include "LPD8806.h"
#include "SPI.h"
int dataPin = 2;
int clockPin = 3;
const int numPixels = 32;
LPD8806 strip = LPD8806(32, dataPin, clockPin);
int i;
uint32_t c;
// Set all pixels to red
c = Color(255,0,0);
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
delay(100);
// Wipe from middle:
c = Color(255, 255, 255); // white
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.show();
delay(100);
}#include "LPD8806.h"
#include "SPI.h"
int dataPin = 2;
int clockPin = 3;
const int numPixels = 32;
LPD8806 strip = LPD8806(32, dataPin, clockPin);
void setup()
{
// Start up the LED strip
strip.begin();
}
void loop() {
int i;
uint32_t c;
c = strip.Color(255, 0, 0); // red
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.show();
delay(100);
}
c = strip.Color(255, 255, 255); // white
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.show();
delay(100);
}
c = strip.Color(0, 0, 255); // blue
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.show();
delay(100);
}
c = strip.Color(0, 255, 0); // green
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.show();
delay(100);
}
}
void setup()
{
// Start up the LED strip
strip.begin();
}
void loop() {
int i;
uint32_t c;
uint32_t b;
c = strip.Color(200, 200, 200); // white - running color
b = strip.Color(255, 0, 0); // red - background color
for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(i + 1, b); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
strip.setPixelColor(strip.numPixels() - 2 - i, b); // right pixel
strip.show();
delay(25);
}
}
void loop() {
int i;
uint32_t c;
uint32_t b;
c = strip.Color(200, 200, 200); // white - running color
b = strip.Color(255, 0, 0); // red - background color
for (i=strip.numPixels() / 2 - 1; i >= -1; i--) { // half of strip, count down to 0
strip.setPixelColor(i, c); // left pixel
strip.setPixelColor(i + 1, b); // left pixel
strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
if (i < 15) strip.setPixelColor(strip.numPixels() - 2 - i, b); // right pixel
strip.show();
delay(25);
}
}Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit
Users browsing this forum: No registered users and 4 guests