NeoPixel Cheat Sheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

NeoPixel LED Strip

LED Strips are individually addressable ribbons of RGB (red green blue)
lights, meaning that each light on the ribbon can be controlled by itself
and give o any color on the visible color spectrum. Every light on the
strip has its own chip onboard that processes commands given to it by
the Arduino.

Connecting:
1. Solder wires to the 3 pads on the
LED strip. Make sure they are
soldered at the start of the strip (the
arrows should be going away from
the wires).
2. Connect the +5V on the strip to the
5V pin on the Arduino.
3. Connect the GND on the strip to one
of the GND pins on the Arduino.
4. Connect the DIN (Data IN) on the
strip to any of the digital pins on the
Arduino.

NeoPixel LED Strip


Installing the NeoPixel Library:
1. Download the NeoPixel Library from Adafruits Github page. You can find the page by
googling NeoPixel Github.
2. Unzip the downloaded file and change the name of the unzipped folder to
Adafruit_NeoPixel.
3. Open up Arduino, then go to Sketch - Include Library - Add .ZIP Library. Navigate to
the unzipped folder, select the folder itself, and click Choose.

Programming:
This line imports the NeoPixel library to your
Arduino code.

#include <Adafruit_NeoPixel.h>

This line tells the Arduino that we have a


NeoPixel strip with 30 lights plugged into pin
6.

Adafruit_NeoPixel strip = Adafruit_NeoPixel(30, 6,


NEO_GRB + NEO_KHZ800);

begin() sets up the LED strip.


show() tells the LEDs to update.

numPixels() returns the length of the strip,


in this case 30

void setup() {
strip.begin();
strip.show();
}
void loop() {
for (int i = 0; i < strip.numPixels();

setPixelColor(LED, Color) tells the selected


LED to change its color to an RGB value, in
this case (255, 0, 0) or red.

strip.setPixelColor(i, strip.Color(255, 0, 0));


}

show() tells the LED to update. The LEDs wont


change color until this is called.
Each number in the RGB color is on a scale
from 0-255, with 0 being the darkest and 255
being the brightest.*

i++) {

strip.show();
delay(100);
}

Note: If this is too daunting, or if you need inspiration, open up Arduino and go to File - Examples Neopixel - strandtest. Use that as a starting point.
* 255 may seem like an arbitrary number, but this limit occurs because the computer stores each of the color numbers in 8-bit unsigned (a.k.a. positive only)
numbers. This means that because of the way binary works, the maximum number it can store is 28 or 256, but since computers start counting from 0, 255
becomes the 256th and final number.

You might also like