Skip to content

LED Test

LedTest.ino tests the WS2812b LED, known as Neopixel. After setting the LED color to Red, Green, and Blue for one second, it is set to white, and the brightness is incrementally increased to the maximum before decreasing it back to 0.

LedTest.ino
#define LED_PIN 10
#define LED_NUM 1
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel led(LED_NUM, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
Serial.println("STARTED");
led.begin();
led.setBrightness(127);
}
void loop() {
led.clear();
led.show();
delay(1000);
// R
led.setPixelColor(0, 255, 0, 0);
led.show();
delay(1000);
// G
led.setPixelColor(0, 0, 255, 0);
led.show();
delay(1000);
// B
led.setPixelColor(0, 0, 0, 255);
led.show();
delay(1000);
// Brightness
for(int i=0; i<256; ++i) {
led.setPixelColor(0, 255, 255, 255);
led.setBrightness(i);
led.show();
delay(25);
}
for(int i=255; i>0; --i) {
led.setPixelColor(0, 255, 255, 255);
led.setBrightness(i);
led.show();
delay(25);
}
delay(3000);
}