Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Interfacing RGB LED Strip with Arduino with Fade & Color Effect
Arduino Projects

Interfacing RGB LED Strip with Arduino with Fade & Color Effect

Mamtaz AlamBy Mamtaz AlamUpdated:August 22, 20221 Comment4 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Interfacing RGB LED Strip with Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

This post is all about Interfacing RGB LED Strip with Arduino to see fading & rolling of LED in different colour effects.


Overview

In this tutorial, we are going to learn about how to connect a 12v RGB LED Strip with Arduino and how to program Arduino Board to make different colour combinations and fading animations. This RGB Multi-Color LED Strip is Dimmable and can be used to make many DIY LED Projects.

This Strip is a perfect choice for indoor or outdoor decoration on Diwali, Christmas, Parties, Marriage or on other events. Light will change colors and speed automatically and periodically on your choice. It has not only RGB (Red, Green, Blue) but a 16 multicolored Light changer. You can have the DIY selection to create your great led mood lighting.

Check this post: RGB LED Strip Color Control with Bluetooth & Arduino


Bill of Materials

Following are the components required to make this project. All the components can be easily purchased from Amazon. The purchased links are given below:

S.N.ComponentsQuantityPurchase Links
1Arduino UNO Board1Amazon | AliExpress
212V RGB LED Strip1Amazon | AliExpress
3MOSFET IRF540N3Amazon | AliExpress
412V Power Supply1Amazon | AliExpress
5Connecting Wires20Amazon | AliExpress
6Breadboard1Amazon | AliExpress



12V RGB LED Strip

12V RGB LED Strip

The SMD5050 type 12V RGB LED Strip is very popular in market. It operates at 12V, 1.5A DC Power Supply. It can generate colours like RGB, White, Warm White, Red, Green, Blue, Yellow etc. There are a total of 60 LEDs per piece.

RGB LED Strip Specifications

The RGB LED Strip has SMD5050 which has 3 samll sized LED of red , green & blue colour. All the 3 LED has 3 resistors attached to it to prevent the LED from getting damaged due to over voltage.

It has cutting marks after each 3 SMD5050 and is detachable. It has a 3M double-sided adhesive and at the back, it has double-sided copper conductive PCB with a great heat dissipation.

The RGB LED strip has 4 pins with 4 colors like white, red, green, blue. The white color line for supplying 12V Power Supply to it. The 3 RGB line is for supplying digital output signal from microcontroller.




Current/Power Requirements for RGB LED Strip

The problem with the Arduinois that its digital outputs can supply more than 200mA and this strip at full brightness could draw more than 1A. For that we have to put something between the Arduino PWM signal and the LED strip. To do this we have two options, either to use high power BJT or to go with MOSFET.

I tested the current consumption by RGB LED Strip at different conditions. When its glowing to full brightness, the current goes more than 1A. So it is advised to use an adpater of 12V, 1.5A or higher current rating.

Current Requirement of RGB LED Strip


Interfacing RGB LED Strip with Arduino

Now let us learn about interfacing SMD5050 LED Strip with Arduino. For each colour line, we need 1 MOSFET and they need to be rated to handle the max current. It’s about 330mA per meter for each channel, 1.66 A per channel for a 5-meter strip.

I have used an IRF540N N Channel MOSFET. You can use any NPN transistors like TIP120, TIP121, TIP122 of N-Channel MOSFETs like IRF2807, IRF 530, IRFZ44N based on your application you can change the transistors. The difference between these transistors is that they have a different collector-emitter current rating. For example, if you are using a large length of RGB LED strip then to drive them you will be needing high current transistors like IRF540 which have Drain Current (Id): 28 Amps.

Interfacing RGB LED Strip with Arduino Circuit



Connect the IRF540N MOSFET and RGB LED Strip as shown in the Circuit Diagram above. Connect the 1st Pin of IRF540N which is a GATE pin to Arduino PWM Pin as D6, D5, D3 respectively for RGB pin. The 2nd pin of IRF540N MOSFET which is a Drain Pin is connected to RGB LED Pins. And the Source Pin of IRF540N which is the 3rd pin is connected to GND. The IRF540n is working as a switch here. You need to supply 12V DC from external power supply like DC Adapter or 12V Transformer rectifier Circuit.

RGB LED Strip Arduino Connection


Source Code/Program

The Source Code for Interfacing RGB LED Strip with Arduino with Fade & Rolling Color Effect is given below. There is no need of any library for this. You can simply upload the code to the Arduino board.

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 color (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);}



Results

Once the code is uploaded and 12V supply is turned on you will start seeing the LED rolling and fading effect. Some of the LED fading pictures are given below and for full demonstration go through the video below.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInterface Capacitive Soil Moisture Sensor v1.2 with Arduino
Next Article 0-50V DC Voltmeter using Arduino & Seven Segement Display

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 1 Comment

1 Comment

  1. Mike on August 1, 2022 7:46 PM

    After reading this post about how to control the brightness of a LED strip, I have a question about how you are controlling the brightness of the LED strip. Are you “adjusting” the value for each R G B pin and not the voltage to the strip? If so, since the Pin values range from 0 to 255, then am I correct in a value of 128 would turn on the color 50%?

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.