Introduction: How to Use the Pixel LED With Arduino

About: I hold a Master's degree in Computer Science and currently teach STEM and ICT. My focus is on making technology and engineering concepts accessible to students through hands-on projects. I teach topics like ro…

Supplies

Components

  1. Arduino Nano board x 1
  2. WS2811 pixel LED string x 1
  3. Jumper wires.
  4. Breadboard x 1


Step 1: Components

Let’s identify these components.

How to use the Pixel LED with Arduino

Step 2:

Connect this pixel LED string to the Arduino Nano board. For that, use the circuit diagram below. But you can use any digital PIN for this project.

How to use the Pixel LED with Arduino

Step 3:

Now connect it to the computer using a USB cable. Then, download the “Fast LED” library and insert it into the Arduino IDE. Download. Okay, let’s look at the code below.

  1. The complete program of this project –
  2. Pixel LED library — 


Step 4: Code

*pixel LED control with Arduino nano.
Read the code below and use it for any of your creation
*/
#include <FastLED.h>//include library---library link in my blog
#define LED 50//num of leds
#define DATAPIN 3//define arduino pin
#define chip WS2811 //chip name
#define colorArrange RGB//color
CRGB pixel [LED];//create array
void setup() {
FastLED.addLeds<chip, DATAPIN, colorArrange>(pixel, LED);//initializing pixel led
}
void loop() {
runRed();
runGreen();
runBlue();
Fill();
fade();
}
void runRed() {
for (byte a = 0; a <= 50; a ++ ) {
pixel[a] = CRGB::Red;
pixel[a + 1] = CRGB::Red;
FastLED.show();
delay(50);
pixel[a] = CRGB::Black;
pixel[a + 1] = CRGB::Black;
}
}
void runGreen() {
for (byte x = 0; x <= 50; x ++ ) {
pixel[x] = CRGB::Green;
pixel[x + 1] = CRGB::Green;
FastLED.show();
delay(50);
pixel[x] = CRGB::Black;
pixel[x + 1] = CRGB::Black;
}
}
void runBlue() {
for (byte x = 0; x <= 50; x ++ ) {
pixel[x] = CRGB::Blue;
pixel[x + 1] = CRGB::Blue;
FastLED.show();
delay(50);
pixel[x] = CRGB::Black;
pixel[x + 1] = CRGB::Black;
}
}
void Fill() {
for (byte a = 0; a <= 50; a++) {
pixel[a] = CRGB::Red;
FastLED.show();
delay(30);
}
for (byte b = 0; b <= 50; b++) {
pixel[b] = CRGB::Green;
FastLED.show();
delay(30);
}
for (byte c = 0; c <= 50; c++) {
pixel[c] = CRGB::Blue;
FastLED.show();
delay(30);
}
for (byte d = 0; d <= 50; d++) {
pixel[d] = CRGB::Yellow;
FastLED.show();
delay(30);
}
}
void fade() {
for (int w = 0; w <= 50; w++) {
pixel[w] = CRGB(0, 0, 255);
pixel[w + 1] = CRGB(0, 0, 230);
pixel[w + 2] = CRGB(0, 0, 210);
pixel[w + 3] = CRGB(0, 0, 190);
pixel[w + 4] = CRGB(0, 0, 150);
FastLED.show();
delay(50);
pixel[w] = CRGB(0, 0, 0);
pixel[w + 1] = CRGB(0, 0, 0);
pixel[w + 2] = CRGB(0, 0, 0);
pixel[w + 3] = CRGB(0, 0, 0);
pixel[w + 4] = CRGB(0, 0, 0);
FastLED.show();
}
}

This code the first time includes the pixel LED controlling library. Next, we define how many LED bulbs to use. After, define the data pin, chip name, and color arrangement. The code in the void setup function initiates the pixel LED string. Read and understand other code lines. They are included in the “Fast LED” library file.

Step 5:

Now, select the correct board and port. After, click the upload button.

How to use the Pixel LED with Arduino

OK, enjoy this project. The full video guide is below. We will meet in the next post.




Have a good day