
Arduino Quick Start
APIs and example programs related to Chain DualKey RGB LED.
#define LED_PWR_PIN 40
#define LED_SIG_PIN 21
#define NUM_LEDS 2
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel LED(NUM_LEDS, LED_SIG_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pinMode(LED_PWR_PIN, OUTPUT);
digitalWrite(LED_PWR_PIN, HIGH);
LED.begin();
LED.show();
}
void loop() {
// White (all on)
for (int i = 0; i <= NUM_LEDS; i++) { LED.setPixelColor(i, LED.Color(255, 255, 255)); }
LED.show();
delay(500);
// Black (all off)
for (int i = 0; i <= NUM_LEDS; i++) { LED.setPixelColor(i, LED.Color(0, 0, 0)); }
LED.show();
delay(500);
// Red & Green
LED.setPixelColor(0, LED.Color(255, 0, 0));
LED.setPixelColor(1, LED.Color(0, 255, 0));
LED.show();
delay(500);
// Blue & Yellow
LED.setPixelColor(0, LED.Color(0, 0, 255));
LED.setPixelColor(1, LED.Color(255, 255, 0));
LED.show();
delay(500);
// Magenta & Cyan
LED.setPixelColor(0, LED.Color(255, 0, 255));
LED.setPixelColor(1, LED.Color(0, 255, 255));
LED.show();
delay(500);
}Running Effect:
The Chain DualKey RGB LED section uses the Adafruit NeoPixel library. For more related APIs, please refer to the following documents: