Pixel LED light for home decoration | Pixel LED circle
Welcome to the SriTu Hobby. Today, we’re diving into a popular topic: creating a pixel LED circle step by step. This tutorial focuses on using an Arduino UNO board and WS2811 pixel LED string. It features 5 LED patterns that you can learn and apply to your own pixel LED programming projects.
Structure of this Pixel LED circle
This pixel LED circle has 48 LEDs, using a WS2811 pixel LED string with 50 LEDs in total. It’s made up of 4 circles and 12 lines. We’ll discuss how to connect these LEDs later on. To control the pixel LEDs, we use the “FastLED.h” library. This circle includes five patterns that you can create using this library.
OK, let’s do this project step by step. The required components are given below.
- Arduino UNO board x 1 — Our Store / Amazon
- WS2811 pixel LED string x 1 —Amazon
- Jumper wires x 1 — Our Store / Amazon
- Foam board — Amazon /
- Cardboard — Amazon
- 5v power supply x1 — Amazon /
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Arduino UNO board
WS2811 pixel LED string
Jumper wires
Foam board or cardboard
5v power supply
Step 2
Secondly, draw a circle with a radius of 5.5 on the foam board or cardboard. Afterward, cut it out.
Step 3
Thirdly, draw 6 lines at equal distances.
Step 4
Now, divide these lines into 4 pieces as matching 4 LEDs.
Step 5
Then, dig holes in the places marked above.
Step 6
Afterward, connect the LEDs through these holes. To do this, use the picture below.
Step 7
Now, connect this LED string to the Arduino board. For that, use the circuit diagram below.
Step 8
OK, now let’s create the program for this project. It is as follows.
#include <FastLED.h>
#define DATA_PIN 2
#define lines 12
#define circles 4
#define BRIGHTNESS 100
CRGB leds[lines * circles];
#define t 150
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, lines * circles);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
flagcolor(2);
colorRing(4);
pattern3(2);
pattern4(2);
pattern5(1);
}
int bulb(int L, int C) {
uint16_t a;
if (L & 0x01) {
uint8_t x = (circles - 1) - C;
a = (L * circles) + x;
} else {
a = (L * circles) + C;
}
return a;
}
Code explanation
Firstly, the FastLED library is included. Also, data PIN, lines, circles, and LED brightness are included.
#include <FastLED.h>
#define DATA_PIN 2
#define lines 12
#define circles 4
#define BRIGHTNESS 100
Next, an array is created for the LED circle. It includes lines and circles. After, the delay time is included.
CRGB leds[lines * circles];
#define t 150
In the setup function, the library is started and the brightness of these pixel LEDs is set.
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, lines * circles);
FastLED.setBrightness(BRIGHTNESS);
}
The loop function consists of five patterns. They are described one by one below.
void loop() {
flagcolor(2);
colorRing(4);
pattern3(2);
pattern4(2);
pattern5(1);
}
flagcolor(2);
void flagcolor(byte x) {
for (int a = 0; a < x; a++ ) {
for (int b = 0; b < 4; b++) {
leds[bulb(0, b)] = CRGB::Blue;
leds[bulb(1, b)] = CRGB::Blue;
leds[bulb(2, b)] = CRGB::Blue;
leds[bulb(3, b)] = CRGB::Blue;
leds[bulb(4, b)] = CRGB::Blue;
leds[bulb(5, b)] = CRGB::Blue;
leds[bulb(6, b)] = CRGB::Blue;
leds[bulb(7, b)] = CRGB::Blue;
leds[bulb(8, b)] = CRGB::Blue;
leds[bulb(9, b)] = CRGB::Blue;
leds[bulb(10, b)] = CRGB::Blue;
leds[bulb(11, b)] = CRGB::Blue;
FastLED.show();
delay(t);
}
for (int b = 0; b < 4; b++) {
leds[bulb(0, b)] = CRGB::Yellow;
leds[bulb(1, b)] = CRGB::Yellow;
leds[bulb(2, b)] = CRGB::Yellow;
leds[bulb(3, b)] = CRGB::Yellow;
leds[bulb(4, b)] = CRGB::Yellow;
leds[bulb(5, b)] = CRGB::Yellow;
leds[bulb(6, b)] = CRGB::Yellow;
leds[bulb(7, b)] = CRGB::Yellow;
leds[bulb(8, b)] = CRGB::Yellow;
leds[bulb(9, b)] = CRGB::Yellow;
leds[bulb(10, b)] = CRGB::Yellow;
leds[bulb(11, b)] = CRGB::Yellow;
FastLED.show();
delay(t);
}
for (int b = 0; b < 4; b++) {
leds[bulb(0, b)] = CRGB::Red;
leds[bulb(1, b)] = CRGB::Red;
leds[bulb(2, b)] = CRGB::Red;
leds[bulb(3, b)] = CRGB::Red;
leds[bulb(4, b)] = CRGB::Red;
leds[bulb(5, b)] = CRGB::Red;
leds[bulb(6, b)] = CRGB::Red;
leds[bulb(7, b)] = CRGB::Red;
leds[bulb(8, b)] = CRGB::Red;
leds[bulb(9, b)] = CRGB::Red;
leds[bulb(10, b)] = CRGB::Red;
leds[bulb(11, b)] = CRGB::Red;
FastLED.show();
delay(t);
}
for (int b = 0; b < 4; b++) {
leds[bulb(0, b)] = CRGB::White;
leds[bulb(1, b)] = CRGB::White;
leds[bulb(2, b)] = CRGB::White;
leds[bulb(3, b)] = CRGB::White;
leds[bulb(4, b)] = CRGB::White;
leds[bulb(5, b)] = CRGB::White;
leds[bulb(6, b)] = CRGB::White;
leds[bulb(7, b)] = CRGB::White;
leds[bulb(8, b)] = CRGB::White;
leds[bulb(9, b)] = CRGB::White;
leds[bulb(10, b)] = CRGB::White;
leds[bulb(11, b)] = CRGB::White;
FastLED.show();
delay(t);
}
for (int b = 0; b < 4; b++) {
leds[bulb(0, b)] = CRGB::Orange;
leds[bulb(1, b)] = CRGB::Orange;
leds[bulb(2, b)] = CRGB::Orange;
leds[bulb(3, b)] = CRGB::Orange;
leds[bulb(4, b)] = CRGB::Orange;
leds[bulb(5, b)] = CRGB::Orange;
leds[bulb(6, b)] = CRGB::Orange;
leds[bulb(7, b)] = CRGB::Orange;
leds[bulb(8, b)] = CRGB::Orange;
leds[bulb(9, b)] = CRGB::Orange;
leds[bulb(10, b)] = CRGB::Orange;
leds[bulb(11, b)] = CRGB::Orange;
FastLED.show();
delay(t);
}
}
}
colorRing(4);
void colorRing(int x) {
for (int a = 0; a < x; a++ ) {
for (int b = 0; b < 4; b++) {
leds[bulb(0, b)] = CRGB::Blue;
leds[bulb(1, b)] = CRGB::Blue;
leds[bulb(2, b)] = CRGB::Blue;
leds[bulb(3, b)] = CRGB::Blue;
leds[bulb(4, b)] = CRGB::Blue;
leds[bulb(5, b)] = CRGB::Blue;
leds[bulb(6, b)] = CRGB::Blue;
leds[bulb(7, b)] = CRGB::Blue;
leds[bulb(8, b)] = CRGB::Blue;
leds[bulb(9, b)] = CRGB::Blue;
leds[bulb(10, b)] = CRGB::Blue;
leds[bulb(11, b)] = CRGB::Blue;
FastLED.show();
delay(100);
leds[bulb(0, b)] = CRGB::Black;
leds[bulb(1, b)] = CRGB::Black;
leds[bulb(2, b)] = CRGB::Black;
leds[bulb(3, b)] = CRGB::Black;
leds[bulb(4, b)] = CRGB::Black;
leds[bulb(5, b)] = CRGB::Black;
leds[bulb(6, b)] = CRGB::Black;
leds[bulb(7, b)] = CRGB::Black;
leds[bulb(8, b)] = CRGB::Black;
leds[bulb(9, b)] = CRGB::Black;
leds[bulb(10, b)] = CRGB::Black;
leds[bulb(11, b)] = CRGB::Black;
FastLED.show();
delay(100);
}
for (int b = 2; b > 0; b--) {
leds[bulb(0, b)] = CRGB::Blue;
leds[bulb(1, b)] = CRGB::Blue;
leds[bulb(2, b)] = CRGB::Blue;
leds[bulb(3, b)] = CRGB::Blue;
leds[bulb(4, b)] = CRGB::Blue;
leds[bulb(5, b)] = CRGB::Blue;
leds[bulb(6, b)] = CRGB::Blue;
leds[bulb(7, b)] = CRGB::Blue;
leds[bulb(8, b)] = CRGB::Blue;
leds[bulb(9, b)] = CRGB::Blue;
leds[bulb(10, b)] = CRGB::Blue;
leds[bulb(11, b)] = CRGB::Blue;
FastLED.show();
delay(100);
leds[bulb(0, b)] = CRGB::Black;
leds[bulb(1, b)] = CRGB::Black;
leds[bulb(2, b)] = CRGB::Black;
leds[bulb(3, b)] = CRGB::Black;
leds[bulb(4, b)] = CRGB::Black;
leds[bulb(5, b)] = CRGB::Black;
leds[bulb(6, b)] = CRGB::Black;
leds[bulb(7, b)] = CRGB::Black;
leds[bulb(8, b)] = CRGB::Black;
leds[bulb(9, b)] = CRGB::Black;
leds[bulb(10, b)] = CRGB::Black;
leds[bulb(11, b)] = CRGB::Black;
FastLED.show();
delay(100);
}
}
}
pattern3(2);
void pattern3(int x) {
for (int a = 0; a < x; a++ ) {
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Blue;
leds[bulb(b, 1)] = CRGB::Blue;
leds[bulb(b, 2)] = CRGB::Blue;
leds[bulb(b, 3)] = CRGB::Blue;
FastLED.show();
delay(t);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Yellow;
leds[bulb(b, 1)] = CRGB::Yellow;
leds[bulb(b, 2)] = CRGB::Yellow;
leds[bulb(b, 3)] = CRGB::Yellow;
FastLED.show();
delay(t);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Red;
leds[bulb(b, 1)] = CRGB::Red;
leds[bulb(b, 2)] = CRGB::Red;
leds[bulb(b, 3)] = CRGB::Red;
FastLED.show();
delay(t);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::White;
leds[bulb(b, 1)] = CRGB::White;
leds[bulb(b, 2)] = CRGB::White;
leds[bulb(b, 3)] = CRGB::White;
FastLED.show();
delay(t);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Orange;
leds[bulb(b, 1)] = CRGB::Orange;
leds[bulb(b, 2)] = CRGB::Orange;
leds[bulb(b, 3)] = CRGB::Orange;
FastLED.show();
delay(t);
}
}
}
pattern4(2);
void pattern4(int x) {
for (int a = 0; a < x; a++ ) {
for (int b = 0; b < 11; b++ ) {
leds[bulb(0 + b, 0)] = CRGB::Yellow;
leds[bulb(0 + b, 1)] = CRGB::Yellow;
leds[bulb(0 + b, 2)] = CRGB::Yellow;
leds[bulb(0 + b, 3)] = CRGB::Yellow;
leds[bulb(1 + b, 0)] = CRGB::Yellow;
leds[bulb(1 + b, 1)] = CRGB::Yellow;
leds[bulb(1 + b, 2)] = CRGB::Yellow;
leds[bulb(1 + b, 3)] = CRGB::Yellow;
FastLED.show();
delay(100);
leds[bulb(0 + b, 0)] = CRGB::Black;
leds[bulb(0 + b, 1)] = CRGB::Black;
leds[bulb(0 + b, 2)] = CRGB::Black;
leds[bulb(0 + b, 3)] = CRGB::Black;
leds[bulb(1 + b, 0)] = CRGB::Black;
leds[bulb(1 + b, 1)] = CRGB::Black;
leds[bulb(1 + b, 2)] = CRGB::Black;
leds[bulb(1 + b, 3)] = CRGB::Black;
FastLED.show();
}
for (int b = 0; b < 11; b++ ) {
leds[bulb(0 + b, 0)] = CRGB::Red;
leds[bulb(0 + b, 1)] = CRGB::Red;
leds[bulb(0 + b, 2)] = CRGB::Red;
leds[bulb(0 + b, 3)] = CRGB::Red;
leds[bulb(1 + b, 0)] = CRGB::Red;
leds[bulb(1 + b, 1)] = CRGB::Red;
leds[bulb(1 + b, 2)] = CRGB::Red;
leds[bulb(1 + b, 3)] = CRGB::Red;
FastLED.show();
delay(100);
leds[bulb(0 + b, 0)] = CRGB::Black;
leds[bulb(0 + b, 1)] = CRGB::Black;
leds[bulb(0 + b, 2)] = CRGB::Black;
leds[bulb(0 + b, 3)] = CRGB::Black;
leds[bulb(1 + b, 0)] = CRGB::Black;
leds[bulb(1 + b, 1)] = CRGB::Black;
leds[bulb(1 + b, 2)] = CRGB::Black;
leds[bulb(1 + b, 3)] = CRGB::Black;
FastLED.show();
}
for (int b = 0; b < 11; b++ ) {
leds[bulb(0 + b, 0)] = CRGB::Blue;
leds[bulb(0 + b, 1)] = CRGB::Blue;
leds[bulb(0 + b, 2)] = CRGB::Blue;
leds[bulb(0 + b, 3)] = CRGB::Blue;
leds[bulb(1 + b, 0)] = CRGB::Blue;
leds[bulb(1 + b, 1)] = CRGB::Blue;
leds[bulb(1 + b, 2)] = CRGB::Blue;
leds[bulb(1 + b, 3)] = CRGB::Blue;
FastLED.show();
delay(100);
leds[bulb(0 + b, 0)] = CRGB::Black;
leds[bulb(0 + b, 1)] = CRGB::Black;
leds[bulb(0 + b, 2)] = CRGB::Black;
leds[bulb(0 + b, 3)] = CRGB::Black;
leds[bulb(1 + b, 0)] = CRGB::Black;
leds[bulb(1 + b, 1)] = CRGB::Black;
leds[bulb(1 + b, 2)] = CRGB::Black;
leds[bulb(1 + b, 3)] = CRGB::Black;
FastLED.show();
}
}
}
pattern5(1);
void pattern5(int x) {
for (int a = 0; a < x; a++ ) {
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Blue;
leds[bulb(b, 1)] = CRGB::Blue;
leds[bulb(b, 2)] = CRGB::Blue;
leds[bulb(b, 3)] = CRGB::Blue;
FastLED.show();
delay(100);
}
for (int b = 11; b >= 0; b--) {
leds[bulb(b, 0)] = CRGB::Black;
leds[bulb(b, 1)] = CRGB::Black;
leds[bulb(b, 2)] = CRGB::Black;
leds[bulb(b, 3)] = CRGB::Black;
FastLED.show();
delay(100);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Yellow;
leds[bulb(b, 1)] = CRGB::Yellow;
leds[bulb(b, 2)] = CRGB::Yellow;
leds[bulb(b, 3)] = CRGB::Yellow;
FastLED.show();
delay(100);
}
for (int b = 11; b >= 0; b--) {
leds[bulb(b, 0)] = CRGB::Black;
leds[bulb(b, 1)] = CRGB::Black;
leds[bulb(b, 2)] = CRGB::Black;
leds[bulb(b, 3)] = CRGB::Black;
FastLED.show();
delay(100);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Red;
leds[bulb(b, 1)] = CRGB::Red;
leds[bulb(b, 2)] = CRGB::Red;
leds[bulb(b, 3)] = CRGB::Red;
FastLED.show();
delay(100);
}
for (int b = 11; b >= 0; b--) {
leds[bulb(b, 0)] = CRGB::Black;
leds[bulb(b, 1)] = CRGB::Black;
leds[bulb(b, 2)] = CRGB::Black;
leds[bulb(b, 3)] = CRGB::Black;
FastLED.show();
delay(100);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::White;
leds[bulb(b, 1)] = CRGB::White;
leds[bulb(b, 2)] = CRGB::White;
leds[bulb(b, 3)] = CRGB::White;
FastLED.show();
delay(100);
}
for (int b = 11; b >= 0; b--) {
leds[bulb(b, 0)] = CRGB::Black;
leds[bulb(b, 1)] = CRGB::Black;
leds[bulb(b, 2)] = CRGB::Black;
leds[bulb(b, 3)] = CRGB::Black;
FastLED.show();
delay(100);
}
for (int b = 0; b < 12; b++) {
leds[bulb(b, 0)] = CRGB::Orange;
leds[bulb(b, 1)] = CRGB::Orange;
leds[bulb(b, 2)] = CRGB::Orange;
leds[bulb(b, 3)] = CRGB::Orange;
FastLED.show();
delay(100);
}
for (int b = 11; b >= 0; b--) {
leds[bulb(b, 0)] = CRGB::Black;
leds[bulb(b, 1)] = CRGB::Black;
leds[bulb(b, 2)] = CRGB::Black;
leds[bulb(b, 3)] = CRGB::Black;
FastLED.show();
delay(100);
}
}
}
Step 9
Now, select board and port. After, upload this code to the Arduino board.
Step 10
Finally, connect the 5v power supply to this circuit. OK, enjoy this project. The full video guide is given below. So, we will meet in the next tutorial. Have a good day.
Pixel LED light for home decoration | Pixel LED circle