Arduino MKR WiFi 1010 - LED - Blink

Welcome to the foundational Arduino MKR WiFi 1010 LED blink tutorial! This guide teaches you how to control an LED with your Arduino MKR WiFi 1010 board using simple digital output commands. Blinking an LED is the classic first project that every Arduino MKR WiFi 1010 beginner starts with - it's like the "Hello World" of electronics! In this tutorial, you'll learn to connect an LED to your Arduino MKR WiFi 1010, write code to control it, and understand the fundamental concepts of digital output that you'll use in virtually every Arduino MKR WiFi 1010 project you build.

Arduino MKR WiFi 1010 control LED

What You'll Learn:

Real-World Applications:

Hardware Preparation

1×Arduino MKR WiFi 1010
1×Micro USB Cable
1×LED Kit
1×LED (red)
1×LED Module
1×220Ω Resistor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack

Or you can buy the following 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 .

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

Overview of LED

An LED (Light Emitting Diode) is a semiconductor device that emits light when electrical current flows through it. LEDs are perfect for Arduino MKR WiFi 1010 projects because they're inexpensive, energy-efficient, and easy to control.

Why Use LEDs?

  • Visual feedback: See when your Arduino MKR WiFi 1010 is running, processing, or detecting events
  • Low power: LEDs consume very little current (typically 10-20mA)
  • Long lasting: Can last for years of continuous operation
  • Fast response: Turn on/off instantly for blinking or PWM brightness control
  • Safe voltage: Work perfectly with Arduino MKR WiFi 1010's 3.3V logic levels

LED Pinout

An LED has two pins that you need to identify correctly:

LED Pinout
  • Cathode (-) pin: The shorter leg, connects to ground (0 volts)
    • Also indicated by flat edge on LED housing
  • Anode (+) pin: The longer leg, connects to power source
    • Use this pin to control the LED on/off state from your Arduino MKR WiFi 1010

    Important Tip: LEDs are polarity-sensitive - they only work when connected correctly. If your LED doesn't light up, try reversing it!

    How LED Works

    An LED lights up when current flows from the anode (+) to the cathode (-):

    How LED Works

    Basic Operation:

    • Cathode connected to ground (GND)
    • Anode receives HIGH signal (3.3V or 5V) → LED turns ON
    • Anode receives LOW signal (0V/GND) → LED turns OFF

    Brightness Control:

    You can also control LED brightness by sending PWM (Pulse Width Modulation) signals to the anode. The LED brightness varies based on the PWM duty cycle. For details, see the Arduino MKR WiFi 1010 - Fade LED tutorial.

    ※ NOTE THAT:

    • Current-limiting resistor required: LEDs can burn out if they receive too much current. Always use a resistor (typically 220Ω-1kΩ) in series with your LED. The resistor can go between the LED anode (+) and power, or between the cathode (-) and ground - both work!
    • Resistor value: The exact value depends on your LED's specifications and supply voltage. 220Ω is a safe value for most standard LEDs with Arduino MKR WiFi 1010.
    • Built-in resistors: Some LED modules already have resistors built in, so you can connect them directly to Arduino MKR WiFi 1010 pins.

    Arduino MKR WiFi 1010 - LED Control

    The Arduino MKR WiFi 1010 can control LEDs using its digital output pins. When you set a digital pin to OUTPUT mode, you can then control its voltage level:

    • digitalWrite(pin, HIGH): Pin outputs voltage → LED turns ON
    • digitalWrite(pin, LOW): Pin outputs 0V (ground) → LED turns OFF

    By toggling between HIGH and LOW with delays in between, you create a blinking effect!

Wiring Diagram

Connect your LED to the Arduino MKR WiFi 1010 as shown in the diagram below:

The wiring diagram between Arduino MKR WiFi 1010 LED

This image is created using Fritzing. Click to enlarge image

Connection Details:

  • LED Anode (longer leg, +)220Ω ResistorArduino Pin D5
    • The resistor limits current to protect the LED
  • LED Cathode (shorter leg, -)Arduino GND
    • Provides return path for current

    Wiring Tips:

    • Double-check the LED polarity - longer leg is positive (+)
    • Make sure the resistor is in series with the LED (between pin and LED)
    • Use the breadboard to make connections secure
    • Keep wires short and neat for a cleaner circuit

How To Program

Controlling an LED with Arduino MKR WiFi 1010 requires three simple steps:

Step 1: Configure Pin as Output

Set an Arduino MKR WiFi 1010 pin to work as a digital output using the pinMode() function. For example, configure pin D5:

pinMode(5, OUTPUT);

This tells the Arduino MKR WiFi 1010 that pin 5 will send signals out, not receive them.

Step 2: Turn LED OFF

Set the pin to LOW (0V, same as ground) using digitalWrite() to turn the LED off:

digitalWrite(5, LOW);

When the pin is at 0V, no current flows through the LED.

Step 3: Turn LED ON

Set the pin to HIGH (3.3V) using digitalWrite() to turn the LED on:

digitalWrite(5, HIGH);

When the pin outputs 3.3V, current flows through the resistor and LED, making it light up!

Creating a Blink Pattern:

To make the LED blink, alternate between HIGH and LOW states with delays in between. This is exactly what the code below demonstrates.

Arduino MKR WiFi 1010 Code

Detailed Instructions

New to Arduino MKR WiFi 1010? Complete our Getting Started with Arduino MKR WiFi 1010 tutorial first to set up your development environment.

Step 1: Build the Circuit

  • Connect the components to the Arduino MKR WiFi 1010 board following the wiring diagram
  • Double-check LED polarity (longer leg to resistor, shorter leg to GND)

Step 2: Connect Arduino

  • Plug your Arduino MKR WiFi 1010 into your computer's USB port
  • Wait for your computer to recognize the board

Step 3: Prepare Arduino IDE

  • Launch the Arduino IDE on your computer
  • Select the Arduino MKR WiFi 1010 board from Tools > Board menu
  • Select the correct COM port from Tools > Port menu

Step 4: Upload Code

  • Click the Upload button (right arrow icon) in the Arduino IDE
How to upload Arduino MKR WiFi 1010 code on Arduino IDE
  • Wait for "Done uploading" message

Step 5: See the Result

  • Watch your LED blink on and off!
  • The LED should flash once per second (500ms on, 500ms off)
  • If the LED doesn't light up, check your wiring and LED polarity

Experiment with Timing:

Try changing the delay values in the code to create different blink patterns:

  • delay(100) - Fast blink (5 times per second)
  • delay(1000) - Slow blink (once every 2 seconds)
  • delay(250) and delay(750) - Uneven blink (quick flash, long pause)
/* * This Arduino MKR WiFi 1010 code was developed by newbiely.com * * This Arduino MKR WiFi 1010 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-mkr/arduino-mkr-wifi-1010-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 }

Code Explanation

The code above demonstrates a simple LED blink pattern:

setup() Function:

pinMode(5, OUTPUT);
  • Runs once when Arduino MKR WiFi 1010 powers on
  • Configures digital pin D5 as an output
  • Prepares the pin to control the LED

loop() Function:

digitalWrite(5, HIGH); // Turn LED ON delay(500); // Wait 500ms (0.5 seconds) digitalWrite(5, LOW); // Turn LED OFF delay(500); // Wait 500ms
  • Repeats continuously as long as the Arduino MKR WiFi 1010 is powered
  • Sets pin HIGH → LED lights up → waits 500ms
  • Sets pin LOW → LED turns off → waits 500ms
  • Result: LED blinks on and off every half second

※ NOTE THAT:

Important Note about delay(): The code above uses the delay() function, which pauses all Arduino MKR WiFi 1010 operations. This is fine for simple projects, but can be a problem if you need your Arduino MKR WiFi 1010 to do multiple tasks at once. For a non-blocking alternative, see Arduino MKR WiFi 1010 - Blink Without Delay.

Challenge Yourself - Creative Customizations

Once you have the basic LED blinking, try these variations to enhance your skills:

1. Different Blink Patterns

Create unique patterns by varying the delays:

// SOS Morse code pattern digitalWrite(5, HIGH); delay(200); // S: dot digitalWrite(5, LOW); delay(200); digitalWrite(5, HIGH); delay(200); // S: dot digitalWrite(5, LOW); delay(200); digitalWrite(5, HIGH); delay(200); // S: dot digitalWrite(5, LOW); delay(500); digitalWrite(5, HIGH); delay(600); // O: dash digitalWrite(5, LOW); delay(200); digitalWrite(5, HIGH); delay(600); // O: dash digitalWrite(5, LOW); delay(200); digitalWrite(5, HIGH); delay(600); // O: dash digitalWrite(5, LOW); delay(500);

2. Multiple LEDs

Connect and control multiple LEDs at different pins:

void setup() { pinMode(5, OUTPUT); // Red LED pinMode(6, OUTPUT); // Green LED pinMode(7, OUTPUT); // Blue LED } void loop() { digitalWrite(5, HIGH); // Red on delay(500); digitalWrite(5, LOW); // Red off digitalWrite(6, HIGH); // Green on delay(500); digitalWrite(6, LOW); // Green off digitalWrite(7, HIGH); // Blue on delay(500); digitalWrite(7, LOW); // Blue off }

3. Brightness Fading

Use PWM to create a pulsing effect:

void loop() { // Fade in for (int brightness = 0; brightness <= 255; brightness++) { analogWrite(5, brightness); delay(5); } // Fade out for (int brightness = 255; brightness >= 0; brightness--) { analogWrite(5, brightness); delay(5); } }

4. Button-Controlled LED

Add a button to turn the LED on/off:

const int LED_PIN = 5; const int BUTTON_PIN = 2; void setup() { pinMode(LED_PIN, OUTPUT); pinMode(BUTTON_PIN, INPUT_PULLUP); } void loop() { if (digitalRead(BUTTON_PIN) == LOW) { digitalWrite(LED_PIN, HIGH); // Button pressed, LED on } else { digitalWrite(LED_PIN, LOW); // Button released, LED off } }

5. Random Blinking

Create unpredictable patterns:

void loop() { digitalWrite(5, HIGH); delay(random(100, 1000)); // Random on-time digitalWrite(5, LOW); delay(random(100, 1000)); // Random off-time }

Experiment with these ideas and create your own unique LED projects!

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!