Arduino Nano 33 IoT - LED - Blink

This guide shows you how to use the Arduino Nano 33 IoT to make an LED turn on and off. It's one of the basic projects beginners start with.

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×LED Kit with resistor
1×LED (red)
1×220 ohm resistor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
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

LED Pinout

An LED has two pins.

  • Cathode (-) pin: Connect this pin to the ground (0 volts).
  • Anode (+) pin: Use this pin to turn the LED on or off.
LED Pinout

How LED Works

After you connect the negative (-) side to ground:

  • When you connect the power supply (VCC) to the LED's positive side, the LED lights up.
  • When you connect the ground (GND) to the LED's positive side, the LED stays off.
How LED Works

Also, if you send a PWM signal to the anode (+), the brightness of the LED will change based on the PWM duty cycle. For more details, check the Arduino Nano 33 IoT Fade LED tutorial.

※ NOTE THAT:

  • Usually, you need a resistor to keep an LED from burning out. You can put this resistor between the LED’s positive side (+) and the power supply (VCC), or between the LED’s negative side (–) and ground (GND). The correct resistor size depends on the LED's details.
  • Some LEDs already have a resistor built in, so you don't need to add one for them.

Arduino Nano 33 IoT - LED

On the Arduino Nano 33 IoT, you can set the digital output pin to have a voltage of either VCC or GND. By connecting this pin to an LED, you can use a program to turn the LED on or off.

Wiring Diagram between LED and Arduino Nano 33 IoT

The wiring diagram between Arduino Nano and 33 IoT LED

This image is created using Fritzing. Click to enlarge image

How To Program

  • Set an Arduino Nano 33 IoT pin to work as a digital output using the pinMode() function. For example, use pin D5.
pinMode(5, OUTPUT);
  • Set the pin to ground using the digitalWrite() function to turn the LED off.
digitalWrite(5, LOW);
  • Set the pin to VCC using the digitalWrite() function to turn on the LED.
digitalWrite(5, HIGH);

Arduino Nano 33 IoT Code

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 following code and paste it into the Arduino IDE.
/* * 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-blink */ // This function executes one time when the board is powered up or reset void setup() { // set digital pin D5 to operate as an output pinMode(5, OUTPUT); } // This function continuously executes in a loop void loop() { digitalWrite(5, HIGH); // switch the LED on delay(500); // pause for 500 milliseconds digitalWrite(5, LOW); // switch the LED off delay(500); // pause for 500 milliseconds }
  • Build and send your code to the Arduino Nano 33 IoT board by clicking the Upload button in the Arduino IDE.
How to upload Arduino Nano 33 IoT code on Arduino IDE
  • See the result: The LED flashes once every second.

Line-by-line Code Explanation

The Arduino Nano 33 IoT code above explains each line. Please check the comments in the code!

※ NOTE THAT:

The code above uses the delay() function. This function makes the Arduino Nano 33 IoT stop doing other tasks. To avoid this, check out Arduino Nano 33 IoT blink without delay.

Video Tutorial

Language References

※ 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!