LED Strip Single Pixel Example

Step 1 - Build the Project

Single LED Pixel Example Hookup: LED Strip with Red in 5V, Green in 13, Blue in 12, Black in ground.

Topics Covered:


Turn on a single pixel on your LED strip. Play around with the different patterns you can make with only a few lines of code!

Step 2 - Upload the Code

/* * Using a single LED on the LED strip * *The mix of the colors and their values from 0-300 is shown on the graph: * * |b r g b * |\ /\ /\ / * | \ / \ / \ / * | X X X * | / \ / \ / \ * |/___\/___\/___\__ * 0 100 200 300 * Each color has a line that zig-zags from low brightness * The color value of 150 is an equal mix between red & green * The color value of 100 is pure red */ #include "LEDStrip.h" int numPixels = 15; //how many LEDs are on the strip /* * Make the LED strip object LEDStrip strip * = LEDStrip(numPixels, dataPin (DI), clockPin(CI)); */ LEDStrip strip = LEDStrip(numPixels, 13, 12); void setup() { } void loop() { //Set pixel 7 to a color between 0 and 300. Brightess is %: 0 to 100 //The brightness number is optional. You can leave it out by not //writing the second comma or any number after it strip.setPixel(7, 200, 75); strip.draw(); //Draw the pixel } //Change the pixel, color, and brightness values //Use more than line of code to set other pixels as colors. //(c) 2017 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense

Step 3 - Read the Walkthrough

First include the LEDStrip library. This library gives you access to a new set of commands (called methods) that make using the LED Strip easier. Without including the library, the Arduino software won’t recognize the new methods.

To tell the library the name & attributes of your LED Strip, you create an object. In this case, the object is called ‘strip’ and it has 15 pixels, the data pin is number 13, and the clock pin is number 12 on your carrier board.

In the loop, use the .setPixel() method to tell the strip which pixel to light, what color to make that pixel, and what brightness that pixel should be. 

The strip.draw() command sends the setPixel values to the strip so you can see them.


Use this color wheel as a reference for which values in your code will create a certain color. Experiment to find just the right hue!

Color wheel for using the Let's Start Coding LED Strip. A color value of 1 is blue, 50 is pink, 100 is red, 150 is yellow, 200 is green, 250 is cyan, and 299 is back to blue. 300 is white.