LED strip light

What is an LED strip light? How do you choose the right one? How do you control it?

Introduction

LED strips, also known as LED ribbons, are a series of LEDs that can be controlled using an Arduino board.

LED strips, also known as LED ribbons, are a series of LEDs that can be controlled using an Arduino board. This will allow you to control your LED strip using a remote control, a smartphone, or automatically. If your LED strip has fewer than ten LEDs, you can connect it directly to the Arduino board.

However, an LED strip often contains many LEDs, so you will need an external power supply to operate it, as the Arduino board cannot provide the required power.
To control your strip and connect it to the external power supply, you can use one of these two components: a relay or a transistor.

What is the difference between a relay and a transistor?

Both components allow you to connect the Arduino board to your LED strip. However, a relay does not allow you to adjust the brightness of your LEDs, unlike a transistor. Additionally, you won’t be able to change the color of your LEDs with a relay, but this is possible with a transistor.

LED strip pin

The LED strip has three pins:

  • Vcc: to be connected to the 5V pin of the Arduino board or to the transistor/relay.
  • GND: to be connected to the ground of the Arduino board or to the transistor/relay.
  • DIN (Signal): to be connected to the Arduino board or to the transistor/relay.

The different types of LED strips

There are two types of LED strips: addressable, where each LED can display a different color, and non-addressable, where all the LEDs show the same color.

Now, let’s take a look at the different types of LED strips so you can make your choice:

LEDs are most often sold in the form of LED strips. To control them, you will need an external power supply due to the number of LEDs.

This LED ring, offered by Neopixel, consists of 16 addressable LEDs and measures 12 x 8 x 0.3 centimeters. It can be powered by 5V and does not require an external power supply.

This LED circle, also offered by Neopixel, has 7 LEDs. Its dimensions are 12 x 8 x 0.3 centimeters.

Now, let’s see how to control these LEDs using libraries.

Neopixel library

Several libraries can be used to program your LED strip. Notably, Adafruit\_NeoPixel, PololuLedStrip, and FastLED.h.

In our course, we will use the Neopixel library. This one will allow you to program most LED strips.

How to install the library?

To control your LED strip, you will need to install the library in the Arduino IDE.

To do this, go to “Sketch”, then “Include Library”, and “Manage Libraries”, and type Adafruit Neopixel.

If you’re having trouble installing it, we recommend our course on libraries.

How to use the Adafruit Neopixel library?

Let’s look at some functions from the library that might be useful to you.

Here’s how to import the Neopixel library into your program:

Here’s how to configure the library. You pass the pin where the LED strip is connected and the number of LEDs on your strip as parameters:

Allows you to start using the library:

Allows you to turn off the LEDs:

Allows you to assign a color to an LED on the strip. Here, we set the color blue to LED 1:

For the color green, you should write: (0, 255, 0)

For the color red, you should write: (255, 0, 0)

Here is the code to turn on your LED:

LED strip without external power supply

Now, let’s see how to light up LEDs on a small LED strip. This one does not require an external power supply. Here is the circuit:

In our program, we light up the LEDs in blue with a 0.2-second interval:

Here is the result once the project is completed:

LED strip with external power supply

If you need to power a strip with many LEDs, you will require an external power supply. For this, we recommend using a transistor to connect the Arduino board to your LED strip.

Here is an example circuit to operate your LED strip:

The program is exactly the same as for controlling an LED strip without an external power supply.

LED ring

Now let’s see how to operate the LED ring. Here, you won’t need an external power supply due to the number of LEDs. Additionally, the LED ring is powered by 5V.

Here is the circuit:

Here, the program creates a random color and gradually lights up the LEDs.

Here is the result when the project is powered on: