58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#include <Adafruit_NeoPixel.h>
|
|
|
|
const int redPin = 4;
|
|
const int greenPin = 5;
|
|
const int bluePin = 13;
|
|
const int whitePin = 14;
|
|
|
|
#define PIN_WS2812B 27
|
|
#define NUM_PIXELS 182
|
|
|
|
Adafruit_NeoPixel ws2812b(NUM_PIXELS, PIN_WS2812B, NEO_GRB + NEO_KHZ800);
|
|
|
|
void setup() {
|
|
ws2812b.begin();
|
|
|
|
pinMode(redPin, OUTPUT);
|
|
pinMode(greenPin, OUTPUT);
|
|
pinMode(bluePin, OUTPUT);
|
|
pinMode(whitePin, OUTPUT);
|
|
|
|
analogWrite(redPin, 0);
|
|
analogWrite(greenPin, 0);
|
|
analogWrite(bluePin, 0);
|
|
analogWrite(whitePin, 0);
|
|
}
|
|
|
|
void loop() {
|
|
ws2812b.clear();
|
|
|
|
for (int pixel = 0; pixel < NUM_PIXELS; pixel++) { // for each pixel
|
|
ws2812b.setPixelColor(pixel, ws2812b.Color(125, 249, 255)); // it only takes effect if pixels.show() is called
|
|
ws2812b.show(); // update to the WS2812B Led Strip
|
|
|
|
delay(25); // 500ms pause between each pixel
|
|
}
|
|
|
|
analogWrite(redPin, 0);
|
|
analogWrite(greenPin, 0);
|
|
analogWrite(bluePin, 0);
|
|
analogWrite(whitePin, 0);
|
|
analogWrite(redPin, 255);
|
|
delay(1000);
|
|
analogWrite(redPin, 0);
|
|
analogWrite(greenPin, 255);
|
|
delay(1000);
|
|
analogWrite(greenPin, 0);
|
|
analogWrite(bluePin, 255);
|
|
delay(1000);
|
|
analogWrite(bluePin, 0);
|
|
analogWrite(whitePin, 255);
|
|
delay(1000);
|
|
analogWrite(redPin, 125);
|
|
analogWrite(greenPin, 249);
|
|
analogWrite(bluePin, 255);
|
|
delay(2000);
|
|
|
|
}
|