Arduino Neopixel Desk Chair
SOURCE CODE:
#include <Adafruit_NeoPixel.h> #define PIN 7 #define NUMPIXELS 40 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int wait = 20; int color = 0;
void setup() {
strip.begin(); }
void loop() { if (color > 255) { color = 0; }
for (int i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(color)); } strip.show(); delay(wait); color++; }
uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else if (WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } else { WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } }
void loopColor() { for (int color = 0; color < 255; color++) { for (int i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(color)); } strip.show(); delay(wait); } }