How to Control LED Strips With Arduino – Part 1: Single-Color Strips

by dziubym in Circuits > Arduino

85 Views, 3 Favorites, 0 Comments

How to Control LED Strips With Arduino – Part 1: Single-Color Strips

thumb_strip.png

Welcome to Part 1 of my LED strip control series with Arduino! In this first installment, we’ll focus on the simplest type of LED strip: the single-color strip. You’ll learn how these strips work, how to power them safely, and how to control them using an Arduino, a MOSFET, a button, and a potentiometer.

This tutorial sets the foundation for controlling more advanced LED setups — including RGB and individually addressable LED strips — which we’ll cover in Parts 2 and 3.

📺 Prefer video tutorials?

You can follow this project step-by-step on YouTube:

  1. ▶️ LED Strips & Arduino – Understanding 5V and 12V Single-Color Strips: https://youtu.be/ms8_rbJWyoo


Supplies

12.png
  1. Arduino Uno or Nano or compatible clone
  2. N-Channel MOSFET (e.g., IRFZ44N, IRF520, IRLZ44N)
  3. Single-color LED strip (5V or 12V)
  4. 220Ω and 10kΩ resistors
  5. Potentiometer (10kΩ recommended)
  6. Pushbutton
  7. Breadboard
  8. Jumper wires
  9. External power supply (5V or 12V based on your strip)
  10. DC barrel jack (female, for 12V input)

How LED Strips Work – 5V Vs 12V

drop.png
5v.png
12v.png
5_12.png

Single-color LED strips are made up of repeatable segments, each containing LEDs and a resistor. These segments are separated by clearly marked cut lines, allowing you to trim the strip to any length — as long as you cut only along those designated points. These marks are present on both 5V and 12V strips and usually appear as small copper pads or scissor icons.

🔋 5V LED Strips

In a 5V LED strip, each segment typically includes one LED + one resistor wired in series. Multiple such segments are then connected in parallel along the strip.

📊 Current per segment: ~20 mA

📊 Voltage drop per segment: ~3V (LED) + ~2V (resistor) = 5V

📏 Resistor calculation:

R = (V_supply - V_LED) / I
R = (5V - 3V) / 0.02A = 100Ω

💡 Total current = 20 mA × number of segments

This means power requirements increase linearly with the number of segments. Make sure your power supply can supply required current


🔋 12V LED Strips

A 12V strip uses a series of 3 LEDs + 1 resistor per segment. These groups are also arranged in parallel. Why 3 LEDs? Because 3 × 3V = 9V, leaving 3V for the resistor to drop.

📊 Voltage drop: 3 LEDs × 3V = 9V + 3V across resistor = 12V total

📏 Resistor calculation:


R = (V_supply - 3 × V_LED) / I
R = (12V - 9V) / 0.02A = 150Ω

📊 Current per segment: still 20 mA

💡 Total current = 20 mA × number of 3-LED segments

Why You Shouldn’t Power LED Strips Directly From the Arduino (and How to Fix It With a MOSFET)

powerlimits.png
mosfet.png

Now that you understand how LED strips work, it’s time to connect them to your Arduino — but wait! There are critical current limitations you need to know about.

⚠️ Arduino Power Limits (What Can Go Wrong)

The Arduino Uno (and clones like Nano) aren’t built to power hungry loads like LED strips. Here’s why:

📷 [Insert your “powerlimits.png” graphic here]

🔌 Current Limitations:

  1. Max current per I/O pin: 40mA (absolute max), but only 20mA recommended for safety.
  2. Max total current across all pins: 200mA
  3. 5V pin limit:
  4. ~500mA if USB-powered
  5. ~1A if using external barrel jack + onboard regulator

➡️ Example: Even a short strip with 4 segments at 20mA each = 80mA, which exceeds what a single I/O pin should provide.

Solution: Use a MOSFET as a Power Switch

To safely control more LEDs, offload the high-current path to a MOSFET, which acts like a switch. The Arduino sends a signal to the MOSFET’s gate, and the MOSFET connects the LED strip to the main power supply.


🔧 How to Wire It

Use an N-channel logic-level MOSFET like the IRLZ44:

  1. Drain (D) → to LED strip negative terminal
  2. Source (S) → to GND
  3. Gate (G) → to PWM-capable digital pin (e.g. D11), with:
  4. 220Ω resistor between Arduino and gate
  5. 10kΩ pull-down resistor from gate to ground (prevents false triggering)

📏 This lets the Arduino control brightness using PWM, while the LED strip draws power from an external 5V or 12V source.

🧠 Summary

  1. Avoid powering more than 1–2 segments directly from Arduino pins
  2. Use a MOSFET to safely control longer strips
  3. Ensure common ground between Arduino and power supply
  4. Choose PWM-capable pin to allow dimming with analogWrite()


Adding a Button and Potentiometer for On/Off and Brightness Control

circuit5v.png

Now that your LED strip is safely controlled via a MOSFET, let’s make it interactive:

  1. A button will turn the strip on and off
  2. A potentiometer will allow dimming using PWM

🛠️ Wiring the Button and Potentiometer

🟡 Button (On/Off Toggle)

  1. One side → GND
  2. Other side → digital pin 2
  3. Arduino uses the internal pull-up resistor, so no external resistor is needed
  4. Software will use an interrupt to detect button presses

🎚️ Potentiometer (Brightness Control)

  1. Middle pin (wiper) → analog pin A3
  2. Other two pins → 5V and GND
  3. Provides a value between 0–1023 that we’ll map to a PWM brightness (0–255)

🔁 Circuit Recap

  1. The MOSFET gate is still connected to pin 11 through a 220Ω resistor, and pulled low with a 10kΩ resistor.
  2. The strip is powered by a 5V source, and the Arduino controls the MOSFET switching based on button state and potentiometer input.

📋 Summary

This setup gives us:

  1. Safe power handling via the MOSFET
  2. PWM dimming from the potentiometer
  3. Interactive control using a simple pushbutton



Upgrading the Circuit for a 12V LED Strip

circuit12v.png
circuit.png

The good news is: you don’t need to redesign the circuit when switching from a 5V to a 12V LED strip. The same MOSFET-based design still works — the only difference is how you power the strip.

🔋 Key Change: Power Supply

  1. Instead of connecting the LED strip's + line to the Arduino’s 5V pin, you now connect it to an external 12V power source
  2. The MOSFET still switches the negative (GND) side of the strip
  3. Arduino must share ground with the 12V power source for the MOSFET gate signal to work correctly


Writing the Arduino Code – Button Control and PWM Dimming

With the hardware all wired up (whether you’re using a 5V or 12V strip), let’s bring it to life using code. This sketch will let you:

  1. Turn the strip on/off using a pushbutton
  2. Control brightness using a potentiometer
  3. Safely debounce button presses to avoid false triggers
  4. Use PWM output to dim the strip smoothly

💻 Arduino Code


const int ledPin = 11; // PWM pin connected to MOSFET gate
const int buttonPin = 2; // Button with internal pull-up
const int potPin = A3; // Potentiometer pin

volatile bool ledState = false; // LED on/off state
volatile unsigned long lastDebounceTime = 0; // Debounce timer
const unsigned long debounceDelay = 50; // 50ms debounce delay

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up
attachInterrupt(digitalPinToInterrupt(buttonPin), toggleLED, FALLING);
}

void loop() {
int brightness = map(analogRead(potPin), 0, 1023, 0, 255); // Map analog to PWM
if (ledState) {
analogWrite(ledPin, brightness); // Set brightness
} else {
analogWrite(ledPin, 0); // Turn off if LED is off
}
}

// Interrupt function to toggle LED state
void toggleLED() {
unsigned long currentTime = millis();
if (currentTime - lastDebounceTime > debounceDelay) {
ledState = !ledState; // Toggle LED state
lastDebounceTime = currentTime;
}
}

🔍 Code Breakdown

🧠 Pin Assignments


const int ledPin = 11;
const int buttonPin = 2;
const int potPin = A3;
  1. ledPin controls the MOSFET gate using PWM
  2. buttonPin uses interrupt pin 2
  3. potPin reads brightness from the analog potentiometer

🔁 setup() Function


pinMode(buttonPin, INPUT_PULLUP);
attachInterrupt(...);
  1. The button is configured with Arduino’s built-in pull-up, so it reads HIGH when untouched and LOW when pressed.
  2. We attach an interrupt to pin 2 so we can respond instantly to button presses.

💡 loop() Function


int brightness = map(analogRead(potPin), 0, 1023, 0, 255);
  1. Converts the potentiometer’s value into a usable range for PWM brightness.
  2. PWM is only active if ledState is true; otherwise, it's turned off.

⏱️ toggleLED() Interrupt

if (currentTime - lastDebounceTime > debounceDelay) {
ledState = !ledState;
}
  1. Implements a simple software debounce (50ms)
  2. Avoids unwanted multiple toggles from noisy mechanical button presses

✅ What This Code Gives You

  1. Smooth dimming via analog control
  2. Responsive on/off switching using an interrupt (even while adjusting brightness)
  3. A safe and scalable control method whether you're using 5V or 12V LED strips


Real Circuit in Action + Final Thoughts

switched_on.png
max.png

Now that everything is wired and coded, let’s see the actual circuit in action.

These real-life images show how your setup works just like the schematic — and prove how easily Arduino can control even high-power lighting setups with simple, low-cost components.

✅ What You’ve Learned

In this project, you learned how to:

  1. Understand how 5V and 12V LED strips are structured
  2. Calculate resistor values and required power supply current
  3. Safely control LED strips using MOSFETs
  4. Add interactivity using a button and PWM dimming with a potentiometer
  5. Write efficient Arduino code using interrupts and analog input

You now have a solid foundation for expanding into RGB and addressable LED strips — which we’ll explore in Parts 2 and 3.

☕ Support My Work

If you found this tutorial helpful and want to support more projects like this, consider buying me a coffee on Ko-fi!

👉 https://ko-fi.com/mariosideas

Every bit helps me keep building, experimenting, and sharing.

📦 What’s Next?

In Part 2, we’ll connect an RGB LED strip and use Arduino to blend colors, change modes, and control all three channels (R, G, B) via PWM.

Be sure to follow or subscribe so you don’t miss it!