Arduino Nano 33 IoT - LED Module

This tutorial instructs you how to use Arduino Nano 33 IoT to switch and dim a 10mm LED module - the kind of bright, chunky indicator you would mount on the lid of an enclosure to show that a Wi-Fi node is online, that a reading has crossed a limit, or that a message has just been sent. In detail, we will learn:

Arduino Nano 33 IoT LED Module

We suggest:

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×LED Module
1×Breadboard
1×Jumper Wires
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 kits:

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 .

Buy Note: Use the LED Module for easier wiring. It includes an integrated resistor.

Overview of LED Module

Think of the LED module as an LED that has already been given everything it needs to be safe: its resistor and a tiny driver are soldered next to it, so the Arduino Nano 33 IoT only has to say "on" or "off". The LED itself is a 10mm diffused round lamp, much easier to see across a room than the usual 5mm one, sitting on a 20mm x 20mm black PCB. The modules are sold as a pack of five colors - red, yellow, blue, green and white - so each one can carry its own meaning in a project.

LED Module
LED 10mm diffused, round
Colors in the pack red, yellow, blue, green, white
Operating voltage 3.3V to 5V DC
Onboard parts 330Ω LED resistor, 1KΩ resistor on IN, small switching transistor
Logic active HIGH (IN = HIGH turns the LED on)
Connector 3-pin 2.54mm right-angle male header, presoldered
Board size 20mm x 20mm

The LED Module Pinout

LED Module Pinout
image source: diyables.io

The header carries three pins, printed on the board in this order:

  • GND pin: must be connected to GND (0V)
  • VCC pin: must be connected to 3.3V or 5V - the current that lights the LED comes from this pin
  • IN pin: must be connected to a digital output pin of the Arduino Nano 33 IoT. HIGH switches the LED on, LOW switches it off, and a PWM signal sets the brightness

※ NOTE THAT:

The arrangement of pins on a module may differ from one manufacturer to another. It is essential to always refer to the labels printed on the module when using it. Take a close look!

Why It Suits a 3.3V Board

The Arduino Nano 33 IoT works at 3.3V and its pins are not built to supply much current. With a bare LED, the pin has to feed the LED directly, so its limit becomes the LED's limit. On the module, the IN pin only opens and closes the onboard transistor through a 1KΩ resistor, which takes a very small current from the pin. The LED is then fed from VCC instead. That is why the module runs happily from the 3.3V pin of the Arduino Nano 33 IoT, and why its brightness does not depend on how much current a GPIO pin can give. White and blue LEDs need more voltage than red ones, so they may look slightly softer at 3.3V than on a 5V board, but they still light up clearly.

Wiring Diagram

Three wires are all it takes: power the module from the 3.3V pin, share the ground, and drive IN from pin D5, which is one of the PWM-capable pins of the Arduino Nano 33 IoT, so the same wiring is used for both the blink and the fade example.

The wiring diagram between Arduino Nano and 33 IoT LED Module

This image is created using Fritzing. Click to enlarge image

LED Module Arduino Nano 33 IoT
GND GND
VCC 3.3V
IN D5

How To Program For LED Module

No library is required - the module is controlled with the standard Arduino functions.

  • The first step is to specify the Arduino Nano 33 IoT pin that is connected to the IN pin:
#define LED_MODULE_PIN 5
  • Configure that pin as an output in setup():
pinMode(LED_MODULE_PIN, OUTPUT);
  • Write HIGH to switch the LED on, or LOW to switch it off:
digitalWrite(LED_MODULE_PIN, HIGH); // LED on digitalWrite(LED_MODULE_PIN, LOW); // LED off
  • Or write a PWM value from 0 (off) to 255 (full brightness) to choose a level in between:
analogWrite(LED_MODULE_PIN, 128); // about half brightness

Arduino Nano 33 IoT Code for LED Module - Brightness Fade

Here the IN pin receives a PWM signal instead of a plain HIGH or LOW. The brightness climbs from 0 to 255 in steps of 15, then falls back to 0, over and over, giving a slow "breathing" effect that works well as an idle or standby indicator.

/* * 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-module */ #define LED_MODULE_PIN 5 // The Arduino Nano 33 IoT pin D5 (PWM) connected to the IN pin of the LED module #define FADE_STEP 15 // how much the brightness changes on each step (0 to 255 in 17 steps) #define STEP_TIME 80 // pause between two steps (milliseconds) int brightness = 0; // current PWM duty cycle: 0 = off, 255 = full brightness int step_size = FADE_STEP; // positive = getting brighter, negative = getting dimmer void setup() { Serial.begin(9600); // configure the pin that drives the IN pin as an output pinMode(LED_MODULE_PIN, OUTPUT); } void loop() { // send a PWM signal to the IN pin; a wider pulse makes the LED look brighter analogWrite(LED_MODULE_PIN, brightness); Serial.print("Brightness: "); Serial.println(brightness); // move to the next brightness level brightness = brightness + step_size; // turn around when the brightness reaches either end of the range if (brightness <= 0 || brightness >= 255) { brightness = constrain(brightness, 0, 255); step_size = -step_size; } delay(STEP_TIME); }

Detailed Instructions

  • Keep the same wiring - pin D5 already supports PWM.
  • Paste the code above into the Arduino IDE and click Upload.
  • Watch the LED fade in and out, about 1.4 seconds in each direction.
  • Open the Serial Monitor to follow the brightness value step by step.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Nano 33 IoT
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano 33 IoT' on 'COM15')
New Line
9600 baud
Brightness: 180 Brightness: 195 Brightness: 210 Brightness: 225 Brightness: 240 Brightness: 255 Brightness: 240 Brightness: 225 Brightness: 210 Brightness: 195
Ln 11, Col 1
Arduino Nano 33 IoT on COM15
2

To make the breathing faster, lower STEP_TIME; to make it smoother, use a smaller FADE_STEP that still divides 255 evenly, such as 5 or 3.

Additional Knowledge

What really changes when you swap a bare LED for the LED module on the Arduino Nano 33 IoT?

Bare LED LED Module
Series resistor you must add one (for example 220Ω) already on board
Polarity anode (+) and cathode (-) must go the right way pins are labeled GND, VCC, IN
Current for the LED comes from the Arduino Nano 33 IoT pin the VCC pin, switched by a transistor
Brightness on a 3.3V pin limited by what the pin can give set by VCC and the onboard resistor
Mounting legs into a breadboard small PCB with a header, easy to fix in a case

It is evident that the LED module is the easier and safer choice for a finished project or a panel indicator, while a bare LED is still worth learning with, because it shows what the module is doing for you behind the scenes.

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!