Untitled
unknown
c_cpp
2 years ago
715 B
8
Indexable
#include <Adafruit_NeoPixel.h>
// Define the number of LEDs and the data pin
#define NUM_LEDS 3
#define DATA_PIN 3
// Create a NeoPixel object
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, DATA_PIN, NEO_GRBW + NEO_KHZ800);
void setup() {
// Initialize the LED strip
strip.begin();
strip.show();
}
void loop() {
// Set all the LEDs to red
strip.fill(strip.Color(255, 0, 0, 0));
// Show the LEDs
strip.show();
// Wait for a second
delay(1000);
// Loop through each LED and change its color to green
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, strip.Color(0, 255, 0, 0));
// Show the LEDs
strip.show();
// Wait for a second
delay(1000);
}
}
Editor is loading...