• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » 5050 LED Strip with Arduino/ESP32

By Abhishek Ghosh July 9, 2023 10:33 am Updated on July 9, 2023

5050 LED Strip with Arduino/ESP32

Advertisement

5050 LED Strips are cheap LED strips which resemble costlier Neopixel strips but the LEDs in 5050 LED Strips are not individually addressable. That means you can use the animations as one coloured LED at one time. You can run the common old animations such as change of colour, dimming effect etc. But we can not run tricky animations such as chase. 5050 LED Strips are a good choice for interior decoration and similar situations where we need continuous light. The entire strip has the same effect and colour, this is an analogue strip. The 5050 it’s the size of the led 5mmx5mm. Unlike Neopixel strips, these 5050 LED Strips lack the ground pin and there are a total of four connecting pins:

 

  • Pin for red
  • Pin for green
  • Pin for blue
  • Vcc or +ve

 

The required voltage differs and the 5V variant is easy to power (when used with Arduino UNO or ESP32). There are 12V and 24V variants. You’ll need additional hardware, namely three output MOSFETs for each R, G and B channel (these strips use a lot of power). You can use :

  1. IRF540N MOSFET (you can use 5V or 12v strips with it)
    or
    STP16nF06L MOSFET
    or
    S8050 NPN transistor
    or
    BC337 NPN transistor
  2. Three 1k resistor

Avoid using TIP120 as they are a bit old and inferior compared to a proper MOSFET.

Advertisement

---

You can measure the current draw of your 5050 strips on full white (it should be about 1.5Amps/Meter) and see if it divided by 3 is lower than the maximum current in the transistor datasheet. Whatever you use, the circuit diagram will be like this:

5050 LED Strip with Arduino ESP32

(The above circuit diagram is by how2electronics.com)

If you are using Visual Studio Code & platform.io set up then use this project:

Vim
1
https://github.com/Aircoookie/WLED

In this file :

Vim
1
https://github.com/Aircoookie/WLED/blob/main/platformio.ini

For ESP32, comment out the existing default_envs, and remove the semicolon from the default_envs line that mentions esp32dev. Follow their guide.

If you want to just run a test, then you can use this code written by how2electronics.com:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#define RED_PIN 6
#define GREEN_PIN 5
#define BLUE_PIN 3
//   # of milliseconds to pause between each pass of the main Arduino loop
#define Loop_Delay 30
  
//brightness level of each colour (0..255)
  int Brightness_R;
  int Brightness_G;
  int Brightness_B;
//fade step counter for LED cycle through off (510 steps), fade on (255 steps),
//    on (510 steps), fade off (255 steps) 1530 total steps
  int FadeStep_R;  
  int FadeStep_G;
  int FadeStep_B;
//number of times LED has completed a full fade cycle
//  int CycleCountB;
//  int CycleCountR;
//  int CycleCountG;
//used to establish what values to send to LED strip  
//  int ColorValue;
// =====================================
// ARDUINO SETUP ROUTINE
// -------------------------------------
void setup() {
//Serial.begin(9600);
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
//set initial strip color. 0(off) to 255(on). can be anything or nothing.
//This value is constrained to 0 - 255. any number higher than 255 will be rounded down to 255.
//                                      any number lower than 0 will be rounded up to 0.
  Brightness_R = 0;
  Brightness_G = 0;
  Brightness_B = 0;
//Set starting fade step position. -764 to -255 = on (brightness level is 255)
//                                 -254 to 0 = fading on (this number *-1 = brightness level)
//                                 0 to 510 = off (brightness level is 0)
//                                 511 to 765 = fading off (this number - 510 = brightness level
//must each be 510 steps apart for smooth color pauses.
//if pauses removed by commenting out or removing ColorValue if statements and rplacing
//with setLEDS (Brightness_R, Brightness_G, Brightness_B); ,which I've already done, these number
//can be any value from -764 to 765 in any combantion, likely making many unplesant fade patterns,
//but also with many possibilities for interesting patterns.  If all values are 510 steps apart  
//the results will ROY G BIV either forward or backward and starting at different positions
//depending on the values given. the farther off the 510 steps of seperationg the further from
//ROY G BIV the pattern will move.
  FadeStep_R = 0;      //0      These setting for normal ROY G BIV
  FadeStep_G = 325;    //510
  FadeStep_B = 650;    //-510
//Set each LED's fade cycle counter to 0
//  CycleCountB = 0;
//  CycleCountR = 0;
//  CycleCountG = 0;
}
// =====================================
// ARDUINO MAIN LOOP ROUTINE
// -------------------------------------
void loop() {
//decrement each LED's fade step counter by one at the start of each loop
    FadeStep_R = FadeStep_R - 1;
    FadeStep_G = FadeStep_G - 1;
    FadeStep_B = FadeStep_B - 1;
    
//fade red LED according to it's fade step counter.        
if (FadeStep_R == -764) {FadeStep_R = 765;}
if (FadeStep_R < 0) {Brightness_R = FadeStep_R * -1;}  
if (FadeStep_R >= 510) {Brightness_R = FadeStep_R - 510;}
// if (FadeStep_R == -510) {CycleCountR = CycleCountR + 1;} //count + 1 for each full fade cycle
//fade green LED according to it's fade step counter.      
if (FadeStep_G == -764) {FadeStep_G = 765;}
if (FadeStep_G < 0) {Brightness_G = FadeStep_G * -1;}  
if (FadeStep_G >= 510) {Brightness_G = FadeStep_G - 510;}
// if (FadeStep_G == -510) {CycleCountG = CycleCountG + 1;} //count + 1 for each full fade cycle
//fade blue LED according to it's fade step counter.  
if (FadeStep_B == -764) {FadeStep_B = 765;}
if (FadeStep_B < 0) {Brightness_B = FadeStep_B * -1;}  
if (FadeStep_B >= 510) {Brightness_B = FadeStep_B - 510;}
// if (FadeStep_B == -510) {CycleCountB = CycleCountB + 1;} // count + 1 for each full fade cycle
  
//  if step counters are intialized 510 steps appart, -510 is the step in each LED's fade cycle
//  that it will be on full brightness while the other 2 LED's are off.
    Brightness_B = constrain(Brightness_B, 0, 255);
    Brightness_G = constrain(Brightness_G, 0, 255);
    Brightness_R = constrain(Brightness_R, 0, 255);
// if (CycleCountB == 8) {CycleCountB = 0;}  
// if (CycleCountR == 8) {CycleCountR = 0;}
// if (CycleCountG == 8) {CycleCountG = 0;}
    
// if (CycleCountR == 2) {ColorValue = 1 ;} //set point for pattern to pause on red
// if (CycleCountR > 2) {ColorValue = 0;}  
// if (CycleCountG == 4) {ColorValue = 2;}   //set point for pattern to pause on green
// if (CycleCountG > 4) {ColorValue = 0;}
  
// if (CycleCountB == 6) {ColorValue = 3;}   //set point for pattern to pause on blue
// if (CycleCountB > 6) {ColorValue = 0;}
//Send brightness levels to LED strip
setLEDS (Brightness_R, Brightness_G, Brightness_B);
// if (ColorValue == 0) {setLEDS (Brightness_R, Brightness_G, Brightness_B);} // default to fade pattern
// if (ColorValue == 1) {setLEDS (255, 0, 0);}  //LED strip red
// if (ColorValue == 2) {setLEDS (0, 255, 0);}  //LED strip green
// if (ColorValue == 3) {setLEDS (0, 0, 255);}  //LED strip blue
    
//    slow the loop down a bit
    delay (Loop_Delay);
}
    
//    send the LED levels to the Arduino pins
void setLEDS (int ipR, int ipG, int ipB) {
  analogWrite (RED_PIN, ipR);     // send the red brightness level to the red LED's pin
  analogWrite (GREEN_PIN, ipG);
  analogWrite (BLUE_PIN, ipB);}

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to 5050 LED Strip with Arduino/ESP32

  • LED Chaser Effect With PWM Using Arduino

    In our earlier article, We have discussed PWM and informed you that this PWD technology is used in particular for light-emitting diodes (LEDs), as they are often used as backlights on mobile phones or brake lights in newer motor vehicles. Our older article on Breathing LED also uses PWM. This was the sketch, LED is […]

  • Arduino LED Candle : Some Codes to Help You

    Thanks to China for making various designs of LED candles available all over the world. Indeed, most of these LED candles are not closest to the real candle, but they do give us the idea to think around playing around creating our microcontroller controlled LED candle. I was looking for a realistic feel and soon […]

  • Arduino UNO Single NeoPixel Rainbow Blink

    Connecting Single NeoPixel to Arduino is Most Simple. Here is Connection and Sketch For Arduino UNO Single NeoPixel Rainbow Blink.

  • NeoPixel Ring Spinning Effect With Potentiometer Control

    In our previous article, we got a simple spinning effect with the provided sketch. It was easy. We have already mentioned that controlling NeoPixel with PWM can be done both with Arduino and Raspberry Pi. When can control the speed of the spin with a potentiometer, we can use any PWM signal to control the […]

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Market Segmentation in BriefSeptember 20, 2023
  • What is Booting?September 18, 2023
  • What is ncurses?September 16, 2023
  • What is JTAG in Electronics?September 15, 2023
  • iPhone 15 Pro Max Vs Samsung Galaxy S22/S23 UltraSeptember 14, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy