Arduino UNO R4 - LED Strip

Discover how to program the Arduino Uno R4 to control 12V LED strips in this beginner-friendly tutorial. From single-color to RGB LED strips, learn to use relays for dynamic lighting projects. Here’s what you’ll learn:

Start your journey into Arduino programming and LED strip projects today!

Hardware Preparation

1×Arduino UNO R4 WiFi or Arduino UNO R4 Minima
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Relay
1×12V 1-color LED Strip
1×12V RGB LED Strip
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino UNO R4
1×Recommended: Breadboard Shield for Arduino UNO R4
1×Recommended: Enclosure for Arduino UNO R4
1×Recommended: Power Splitter for Arduino UNO R4
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of LED Strip

A LED strip, also called LED tape or LED ribbon, is a flexible board with LEDs that shine light. These strips are flexible and used often for decorative lights in many places. LED strips are available in different colors and are mainly used to create a soft glow, highlight specific areas, or add decorative light effects.

LED strips are available in two primary varieties:

  • Addressable LED Strips: In this type, you can control the color and brightness of each LED separately. Each LED has its own unique address that allows this individual control.
  • Non-Addressable LED Strips: With these strips, you can change the color and brightness too, but the change affects all the LEDs on the strip at the same time.

This guide is about Non-Addressable LED Strips. For Addressable LED Strips, see the other guides provided.

Non-Addressable LED Strip Pinout

There are two main types of Non-Addressable LED Strips.

  • Non-Addressable 1-color LED strip: Comes in only one color set by the manufacturer.
  • Non-Addressable RGB LED strip: Can show many colors.

A Non-Addressable 1-color LED Strip typically has two pins:

  • 12V/24V pin: Connect this to the positive pin of a 12V or 24V DC power supply.
  • GND pin: Connect this to the negative pin of a 12V or 24H DC power supply.

A Non-Addressable RGB LED Strip typically has four pins:

  • 12V/24V pin: Connect this to the positive pin of a 12V or 24V DC power supply.
  • R pin: Use this pin for red color control. Connect it to the power supply's negative pin to activate red color.
  • G pin: Use this pin for green color control. Connect it to the power supply's negative pin to activate green color.
  • B come: Use this pin for blue color control. Connect it to the power supply's negative pin to activate blue color.
Arduino UNO R4 non-addressable led strip Pinout

We will learn how to control both types using the Arduino UNO R4, one at a time.

How to Control a Non-Addressable 1-color LED strip.

When you connect a 12V LED strip to a 12V power supply, it will light up. To control this 12V LED strip using an Arduino UNO R4, you must use a relay. The Arduino UNO R4 controls the 12V LED strip through the relay. If you are not familiar with relays, such as their pinouts, functions, or programming, you can learn more by visiting the Arduino UNO R4 - Relay tutorial at Arduino UNO R4 - Relay tutorial.

Wiring Diagram.

Wiring Diagram between Arduino UNO R4 and Non-Addressable 1-color LED strip.

The wiring diagram between Arduino UNO R4 12V LED strip

This image is created using Fritzing. Click to enlarge image

Wiring Diagram between Arduino UNO R4 and Non-Addressable RGB LED strip.

The wiring diagram between Arduino UNO R4 12V LED strip

This image is created using Fritzing. Click to enlarge image

See The best way to supply power to the Arduino Uno R4 and other components.

Arduino UNO R4 Code

Arduino UNO R4 Code for controlling Non-Addressable 1-color LED strip.

This code will continuously turn the LED strip on for 5 seconds and then off for 5 seconds.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-led-strip */ #define LED_STRIP_PIN 3 // The Arduino Uno R4 pin controls to the LED strip via relay void setup() { Serial.begin(9600); // initialize Arduino pins as digital output pins pinMode(LED_STRIP_PIN, OUTPUT); } // the loop function runs over and over again forever void loop() { Serial.println("The LED strip is turned on"); digitalWrite(LED_STRIP_PIN, HIGH); delay(5000); Serial.println("The LED strip is turned off"); digitalWrite(LED_STRIP_PIN, LOW); delay(5000); }

Arduino UNO R4 Code for controlling Non-Addressable RGB LED strip.

The code below repeatedly changes the colors of the RGB LED strip (red, green, blue, yellow, magenta, cyan, and white).

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-led-strip */ #define BLUE_PIN 5 // The Arduino Uno R4 pin connects to the blue pin of LED strip via relay 1 #define RED_PIN 6 // The Arduino Uno R4 pin connects to the red pin of LED strip via relay 2 #define GREEN_PIN 7 // The Arduino Uno R4 pin connects to the green pin of LED strip via relay 3 void setup() { Serial.begin(9600); // initialize Arduino pins as digital output pins pinMode(BLUE_PIN, OUTPUT); pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); } // the loop function runs over and over again forever void loop() { Serial.println("The LED strip is turned red"); digitalWrite(BLUE_PIN, LOW); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); delay(2000); Serial.println("The LED strip is turned green"); digitalWrite(BLUE_PIN, LOW); digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); delay(2000); Serial.println("The LED strip is turned blue"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, LOW); delay(2000); Serial.println("The LED strip is turned yellow"); digitalWrite(BLUE_PIN, LOW); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); delay(2000); Serial.println("The LED strip is turned magenta"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); delay(2000); Serial.println("The LED strip is turned cyan"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); delay(2000); Serial.println("The LED strip is turned white"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); delay(2000); }

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Wire the the LED strip to Arduino Uno R4 according to the provided diagram.
  • Connect the Arduino Uno R4 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • Copy the code provided above and paste it into the Arduino IDE.
  • Click the Upload button in the Arduino IDE to transfer the code to your Arduino UNO R4.
  • Observe the condition of the LED strip.

Code Explanation

The explanation is in the comments of the Arduino code above.

To adjust the brightness and colors of a non-addressable LED strip, we must use a driver like L298N driver instead of a relay.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!