The rise of LED lighting has been stratospheric and it’s easy to see why. They are cheap to manufacture, use significantly less energy than other lighting options, and do not heat up in most cases, making them safe for a variety of applications.
We will also use the Arduino IDE to control them. This project uses an Arduino Uno, although you can use just about any compatible board (e.g. NodeMCU.).
Choose your lane
When shopping for LED strips, there are a few things to consider. First, it’s functionality. If you plan to use the strips primarily for ambient lighting, then a simple LED band RGB 12V ( SMD5050 ).
Many of these strips come with an infrared remote to control them, although for this project we will be using an Arduino instead. Spend some time shopping, at the time of writing you could get these strips for as little as $1 a meter.
If you want something a little higher, consider WS2811 / 12 / 12B . These bands (sometimes called neopixels ) have built-in chipsets that allow them to be accessed individually. This means that they are capable of more than just ambient lighting.
These strips only require 5V to power them. Although they can be powered in small portions directly from the Arduino board, it is generally recommended to use a separate 5V power supply to keep yourself from the smell of a fried Arduino. If you are looking for individually programmable LEDs, these are for you. At the time of writing, they are available for about $4 per meter.
Another thing to consider is where these bands can be used. Both types of strips come in different lengths, LED densities (number of LEDs per meter) and varying degrees of weather protection.
To connect a 12V LED strip to an Arduino, you will need a few components:
- 12v RGB led strip ( SMD5050 )
- 1 x Arduino Uno (any compatible board will do)
- Resistors 3 x ten kOhm
- 3 x N-channel MOSFETs with logic level
- 1 x breadboard
- Connecting wires
- 12v power supply
Before setting up the schema, let’s talk about MOSFETs .
Whenever you are driving something that is at a higher voltage than your microcontroller, you need something in between to keep your board from frying. One of the easier ways to do this is to use a MOSFET. By sending pulse width modulation signals ( PWM ) per branch shutter you can control how much energy passes between the branches runoff and source . By passing each of the LED strips through a MOSFET, you can control the brightness of each individual color on the LED strip.
When using microcontrollers, it’s important to use logic level components to ensure everything works the way you want. Make sure your MOSFETs are logic level and are not standard .
Set up your schema like this:
- Connect Arduino Pins 9 , 6 and 5 to gate branches three MOSFETs and connect a resistor ten kOhm on the line of each to the ground bus.
- Connect the legs source to the ground bar.
- Connect drain legs to green , red and blue connectors on the LED strip.
- Connect the power rail to the connector + 12V led strip (note that the power wire is black in this image to match the colors of the connectors on my led strip).
- Connect the Arduino ground to the ground rail.
- Connect a 12V power supply to tires nutrition.
We will be powering our Arduino board via USB for this project. You can power up your board using the VIN pin, but before doing so, make sure you know the power limits for your board.
When your circuit is complete, it should look something like this:
Now that you’ve got everything connected, it’s time to make a simple Arduino sketch to control it.
fade it up
Connect the Arduino board to your computer via USB and open the Arduino IDE. Make sure you have the correct board and port number selected for your board in menu Tools> Fee and Tools> Menu ports . Open a new sketch and save it with an appropriate name.
This sketch will fade the lights out one color at a time, keep them on for a few seconds, and then fade out until they turn off again. You can go here and sketch it yourself, or just download the full code from GitHub.
Start by determining which contacts will be used to drive the MOSFETs.