Arduino Nano 33 IoT - LED Strip
This lesson will teach you how to code the Arduino Nano 33 IoT to control a 12V RGB LED light strip and single color 12V LED strip.
Two kinds of switches are used here: a relay and a MOSFET module. With the relay, the strip is either fully lit or dark. With the MOSFET module, the strip can also be dimmed to any brightness you like. You will learn to use both of them.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of LED Strip
An LED strip, sometimes called LED tape or LED ribbon, is a flexible board with tiny LED lights attached. These strips are very useful and are usually used for creative lighting in different areas. LED strips come in many colors and are often used to add soft light, highlight special spots, or create attractive decoration.
There are two main kinds of LED strips:
- Addressable LED Strips: In these strips, you can change each LED's color and brightness separately because every LED has its own unique number.
- Non-Addressable LED Strips: In these strips, you can change the color and brightness, but all LEDs change the same way.
This guide will talk about Non-Addressable LED Strips. For tutorials on Addressable LED Strips, please see the ones listed below.
Non-Addressable LED Strip Pinout
Non-addressable LED light strips come in two main types:
- Basic single-color LED strip: The maker sets it to show only one color.
- RGB LED strip: It can display many different colors.
A basic one-color LED strip that cannot be controlled individually normally comes with two pins.
- 12V/24V pin: Connect this to the positive terminal of a 12V or 24V DC power supply.
- GND pin: Connect this to the negative terminal of a 12V or 24V DC power supply.
A basic RGB LED strip that isn’t individually controlled usually has four pins.
- 12V/24V pin: Connect this to the positive terminal of a 12V or 24V DC power supply.
- R pin: This pin controls the red light. When you connect it to the negative terminal, the red light turns on.
- G pin: This pin controls the green light. When you connect it to the negative terminal, the green light turns on.
- B pin: This pin controls the blue light. When you connect it to the negative terminal, the blue light turns on.

We will learn how to control both types using the Arduino Nano 33 IoT, one at a time.
A MOSFET module is a good partner for these strips. If you have never used one, start with the Arduino Nano 33 IoT - MOSFET Module tutorial.
Relay vs MOSFET Module for LED Strip
| Relay | MOSFET Module | |
|---|---|---|
| Light control | Lit or dark | Lit, dark, and dimmed to any brightness (PWM) |
| Click sound | Yes | None |
| Switch speed | Milliseconds, slow | Very quick |
| Life of the switch | Limited, the contacts wear | Long, no moving parts |
| Strip power | AC or DC | DC only |
| Strip voltage | Whatever the relay is rated for | 6V or more (12V and 24V strips are fine) |
| Isolation from the board | Yes, coil and contacts | Yes, PC817 optocoupler |
| Best for | Simple ON/OFF lighting | Dimming 12V/24V strips and soft light effects |
For a single-color 12V or 24V strip, the MOSFET module is the easier way to get dimming. An RGB strip has three color channels (R, G and B), so it needs three MOSFET modules, one per color, in the same way it needs three relays.
How to Control a Non-Addressable 1-color LED strip.
When a 12V LED strip is connected to a 12V power supply, it lights up. To control the LED strip, we use a relay that sits between the Arduino Nano 33 IoT and the LED strip. The Arduino Nano 33 IoT sends commands through the relay to the LED strip. If you are not familiar with relays, their pins, how they work, or how to program them, check out the Arduino Nano 33 IoT - Relay tutorial.
Wiring Diagram.
Wiring Diagram between Arduino Nano 33 IoT and Non-Addressable 1-color LED strip.

This image is created using Fritzing. Click to enlarge image
Wiring Diagram between Arduino Nano 33 IoT and Non-Addressable RGB LED strip.

This image is created using Fritzing. Click to enlarge image
Arduino Nano 33 IoT Code
Arduino Nano 33 IoT Code for controlling Non-Addressable 1-color LED strip.
The following code repeatedly turns the LED strip on for 5 seconds and then off for 5 seconds.
Arduino Nano 33 IoT Code for controlling Non-Addressable RGB LED strip.
The code below continuously changes the colors of the RGB LED strip (red, green, blue, yellow, magenta, cyan, and white).
Detailed Instructions
If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:
- Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
- Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
- Launch the Arduino IDE on your computer.
- Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
- Copy the code above and paste it into the Arduino IDE.
- Click the Upload button in the Arduino IDE to send the code to the Arduino Nano 33 IoT.
- Look at the LED strip to see its status.
Code Explanation
You can see the explanation in the comments above the Arduino code.
Remember, to change the brightness and colors of a regular LED strip, you need to use the L298N driver instead of a relay.
How to Dim a 1-color LED Strip with MOSFET Module
In this part, a MOSFET module switches the single-color LED strip in place of the relay. By changing the PWM value, the Arduino Nano 33 IoT makes the strip brighter or dimmer.
Wiring Diagram between Arduino Nano 33 IoT, MOSFET Module and 1-color LED Strip

This image is created using Fritzing. Click to enlarge image
- Arduino Nano 33 IoT D9 goes to the module PWM pin.
- Arduino Nano 33 IoT GND goes to the module GND pin.
- The 12V adapter + and the strip 12V/24V pin both go to the + terminal.
- The strip GND pin goes to the LOAD terminal.
- The 12V adapter − goes to the − terminal.
An LED strip has no coil, so you do not need a flyback diode. For a 24V strip, use a 24V adapter instead.
Arduino Nano 33 IoT Code for dimming Non-Addressable 1-color LED strip
The strip shines at full brightness for 2 seconds and goes dark for 2 seconds. Then it slowly gets brighter from 10% to 100%, and slowly gets dimmer back to off.
Detailed Instructions
- Get the Arduino IDE and the board ready, as in the Quick Steps for the relay above.
- Wire the strip to the MOSFET module as in the diagram, with the adapter unplugged.
- Paste the code into the Arduino IDE and upload it.
- Plug in the power adapter of the strip.
- Open the Serial Monitor at 9600 baud and compare the numbers with the brightness of the strip.
※ NOTE THAT:
The MOSFET module switches DC only, and the strip supply must be about 6V or more. Keep the relay if you want to switch an AC light.