Skip to content

Instantly share code, notes, and snippets.

@rahulbot
Created February 16, 2023 18:29
Show Gist options
  • Save rahulbot/b069e61397417e88c4895746fdb2cb38 to your computer and use it in GitHub Desktop.
Save rahulbot/b069e61397417e88c4895746fdb2cb38 to your computer and use it in GitHub Desktop.
Arduino Simple NeoPixel Example
#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