Created
February 16, 2023 18:29
-
-
Save rahulbot/b069e61397417e88c4895746fdb2cb38 to your computer and use it in GitHub Desktop.
Arduino Simple NeoPixel Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define PIN_NEO_PIXEL 8 // Arduino pin that connects to NeoPixel | |
#define NUM_PIXELS 21 // The number of LEDs (pixels) on NeoPixel | |
#define DELAY_INTERVAL 100 | |
Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800); | |
void setup() { | |
NeoPixel.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) | |
} | |
void loop() { | |
NeoPixel.clear(); | |
for (int pixel = 0; pixel < NUM_PIXELS; pixel++) { // for each pixel | |
NeoPixel.setPixelColor(pixel, NeoPixel.Color(0, 255, 0)); // it only takes effect if pixels.show() is called | |
NeoPixel.show(); // send the updated pixel colors to the NeoPixel hardware. | |
delay(DELAY_INTERVAL); // pause between each pixel | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment