How to blink a D1 Mini onboard LED (Windows, 7 Steps)

In this article I show you how to blink the onboard LED of a WeMos D1 Mini board. These instructions were written using a Windows 10 Home laptop (click here for the Mac instructions).

To blink the onboard LED of a D1 Mini board you can program it like an Arduino board. Once you add support for the board to the Arduino IDE, you can write and run a simple blink example.

In the steps below, I will show you how to do that.

Where to buy

Several manufacturers create their own version of the WeMos D1 Mini board. If you would like to use the one that I used for this article, you can buy it from Amazon in the US using my affiliate link (note that this is a 2 Pack):

The model I use has a micro-USB connection. So I used a cable from one of my Android devices. You could try this cable:

Step 1. Plug the D1 Mini into your Windows machine

The first thing that you need to do is plug the D1 Mini board into your Windows machine. The board will be powered by the USB cable for this example. So you won't need an external power supply.

  • Plug the USB cable into your Windows laptop or PC
  • Plug the USB cable into your D1 Mini board

Step 2. Download the Arduino IDE

This article was tested using the Arduino IDE version 1.8.15.

Windows Instructions

There may be multiple versions for Windows listed. I suggest downloading the *.exe installer. Currently that is the one labeled “Win 7 and newer.” If you see different labels, wave your mouse over each of them and pick the one whose link ends with exe.

  • You should see the downloaded file in the footer of your browser
  • Click on it and select Show in Folder
  • If not, you can find the file in File Explorer in the Downloads folder in your user directory
  • To install, run the executable – it will be labeled something like arduino-1.8.15-windows.exe depending on what version you downloaded
  • During installation you will be prompted to approve various steps along the way – if the requests sound reasonable, click Yes
  • If you are prompted to accept terms, you may read them and assuming that you are fine with them, click I Agree
  • When prompted for what components to install I would recommend installing all of them
  • This will install the Arduino software, USB driver, Start Menu and Desktop shortcuts and associate .ino files with the Arduino IDE, etc.
  • Depending on how your Windows machine was setup and what version you have, the Arduino software will default to being installed in C:\Program Files (x86)\Arduino\
  • Once the installation has finished, click Close

Step 3: Configure the Arduino IDE for D1 Mini boards

  • Start the Arduino IDE
  • From the File menu select Preferences...
  • For Additional Board Manager URLs enter in the field on its own line:
https://arduino.esp8266.com/stable/package_esp8266com_index.json
  • Select from the Tools menu Board: * > Boards Manager...
  • Type in esp8266
  • You should see a listing for esp8266 by ESP8266 Community
  • Click Install
  • Click Close

Step 4. Select your board

  • Select Tools > Board: *
  • Select your board (I selected LOLIN(WEMOS) D1 R2 & Mini)

Step 5: Run the example Blink sketch

  • Select File > Examples > 01. Basics > Blink

The code should look something like this:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // Arduino: turn the LED on (HIGH)
                                     // D1 Mini: turns the LED *off*
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // Arduino: turn the LED off (LOW)
                                     // D1 Mini: turns the LED *on*
  delay(1000);                       // wait for a second
}

Code description

On the D1 Mini the LED_BUILTIN is backwards

For a standard Arduino, pulling the LED_BUILTIN to HIGH would turn the LED on. But on D1 Mini that actually turns the LED off. You will note that I added some comments to the default example above. So be aware that the comments in the default Blink code are backwards.

  • The setup function sets up the onboard LED as an output pin, so it can be turned on and off
  • The loop repeatedly turns the LED on and off by toggling the voltage level between HIGH and LOW
  • Delays are used to control how quickly the LED turns on and off

Step 6: Upload the code to the D1 Mini

  • Click the Upload button (the right pointing arrow in the IDE tool bar)

Step 7: Verify it works

  • Verify that you see the onboard LED blinking on and off

On my board the LED is blue.

Next step

You can experiment with this simple example by changing the delay values and uploading new code to the device. Make the delay different enough so that you can confirm that your changes are working.

Conclusion

The D1 Mini board is part of a family of open hardware devices. Not all devices look or act the same but they are based on the same chipset. So if you are using a different device you may get different results.

Treating the D1 Mini board as an Arduino is only one option. But a good place to start as a beginner.

Related articles

See my related articles, where I show how to blink the LED for other types of Arduino boards:

References

  • Arduino core for ESP8266 WiFi chip [1]