⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

Flashing a 12V White LED Strip

Have you ever wondered how to use an Arduino to control more powerful lighting, like the 12V LED strip you have at home? Even though Arduino operates on 5V, we can control much more powerful devices with a simple trick.

Why can't it be connected directly?

Arduino pins are like small switches that can only handle about 20-40mA of current. An LED strip "consumes" much more and also requires 12V of voltage. If you connected it directly, the Arduino would burn out. The solution? A MOSFET transistor.

Wiring instructions for the IRLZ44N MOSFET:

  1. G (Gate - pin 1): Connect to Arduino Pin 9.
  2. D (Drain - pin 2): Connect to the negative (-) terminal of the LED strip.
  3. S (Source - pin 3): Connect to Arduino GND and the negative (-) terminal of the power supply.
Project Logic: The MOSFET acts as an electronic switch. The Arduino tells it to "turn on," and the MOSFET allows 12V current from the power supply to flow through the LED strip. Simple and safe!

What do you need?

Wiring in three steps:

  1. GND: Connect the Arduino GND and the 12V power supply negative (-) terminal together (this is essential!).
  2. Control: Connect Arduino Pin 9 to the "Gate" (first leg) of the MOSFET.
  3. Power: Connect the LED strip between the +12V power supply terminal and the "Drain" (middle leg) of the MOSFET.

Below is the code that will make your strip flash at one-second intervals.

Result: Once you upload the code to the Arduino, your 12V LED strip will flash at one-second intervals. This is the foundation for all future projects involving the control of higher-power loads.
// 12V LED strip flashing
// Author: Borut Bukovnik - vadnica.org

int ledPin = 9; // MOSFET Gate pin

void setup() {
    pinMode(ledPin, OUTPUT);
}

void loop() {
    digitalWrite(ledPin, HIGH); // Turn on the strip
    delay(1000); 
    digitalWrite(ledPin, LOW);  // Turn off the strip
    delay(1000); 
}