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.

Arduino Nano 33 IoT 12V LED strip

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Relay
1×12V 1-color LED Strip
1×12V RGB LED Strip
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×Alternatively, 24V 1-color LED Strip
1×Alternatively, 24V RGB LED Strip
1×Alternatively, 24V Power Adapter
1×Optionally, 5V Power Adapter for Arduino Nano 33 IoT
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
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.
Arduino Nano 33 IoT non-addressable led strip Pinout

We will learn how to control both types using the Arduino Nano 33 IoT, one at a time.

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.

The wiring diagram between Arduino Nano and 33 IoT 12V 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.

The wiring diagram between Arduino Nano and 33 IoT 12V 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.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-led-strip */ #define LED_STRIP_PIN 5 // The Arduino Nano 33 IoT pin controls to the LED strip via relay void setup() { Serial.begin(9600); // initialize Arduino Nano 33 IoT pins as digital output pins pinMode(LED_STRIP_PIN, OUTPUT); } // The loop function repeats indefinitely void loop() { Serial.println("The LED strip is turned on"); digitalWrite(LED_STRIP_PIN, HIGH); delay(5000); Serial.println("The LED strip is turned off"); digitalWrite(LED_STRIP_PIN, LOW); delay(5000); }

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).

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-led-strip */ #define BLUE_PIN 6 // The Arduino Nano 33 IoT pin connects to the blue pin of LED strip via relay 1 #define RED_PIN 5 // The Arduino Nano 33 IoT pin connects to the red pin of LED strip via relay 2 #define GREEN_PIN 4 // The Arduino Nano 33 IoT pin connects to the green pin of LED strip via relay 3 void setup() { Serial.begin(9600); // initialize Arduino Nano 33 IoT pins as digital output pins pinMode(BLUE_PIN, OUTPUT); pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); } // The loop function repeats indefinitely void loop() { Serial.println("The LED strip is turned red"); digitalWrite(BLUE_PIN, LOW); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); delay(2000); Serial.println("The LED strip is turned green"); digitalWrite(BLUE_PIN, LOW); digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); delay(2000); Serial.println("The LED strip is turned blue"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, LOW); delay(2000); Serial.println("The LED strip is turned yellow"); digitalWrite(BLUE_PIN, LOW); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); delay(2000); Serial.println("The LED strip is turned magenta"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); delay(2000); Serial.println("The LED strip is turned cyan"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); delay(2000); Serial.println("The LED strip is turned white"); digitalWrite(BLUE_PIN, HIGH); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); delay(2000); }

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.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!