If you read my previous post on setting up a Wemos D1 Mini, you’ll know that I’m new to the board – like really new.
Anything outside of the Raspberry Pi is generally new territory for me, but that’s kind of fun at the same time. It’s like starting all over again!
So, despite stating how much LED projects bore me, I’m showing you a really simple Wemos LED project today. You just can’t beat a project like this as a first uneasy step into hardware control with a new board.
Let’s get blinky…
What you need
It’s a very small shopping list today, and some of you may have this stuff to hand already:
- A Wemos D1 Mini (this is what I’m using – other Wemos boards may behave differently in terms of GPIO & pin numbering)
- A ‘standard’ 5mm LED
- A mini breadboard
- A 330-ohm resistor
Breadboard Setup
You’ll need a way of breaking out your Wemos pins to a breadboard. The Wemos boards usually come with headers included in the bag, and I’ve soldered the male headers facing downwards for easy breadboard use:

Soldering male headers in this direction is ideal when using a breadboard
Push your Wemos into the mini breadboard at one end, so that the micro-USB is hanging over the edge (allowing you to plug it in).
Then run a resistor from the GND (G) pin to an empty lane on the breadboard. Next, connect the shorter (cathode) leg of your LED to the same lane, and the longer leg (anode) to the opposite lane.
Finally, run your jumper wire from the anode LED leg lane to the D7 pin on your Wemos.
That’s a lot of words for something that’s probably best described in pictures – so take a look below:
My Circuit:
Fritzing diagram (ignore resistor colours):
Wemos LED Sketch
If you read my guide on setting up the Wemos, you’ll already have the Arduino IDE set up and ready. If not, go read that now.
Fire up the IDE and copy the following code into a new sketch:
int LED = D7; void setup() { pinMode(LED, OUTPUT); // Make LED pin D7 an output pin } void loop() { digitalWrite(LED, LOW); // LED off delay(3000); // Wait 3 seconds digitalWrite(LED, HIGH); // LED on delay(1000); // Wait 1 second }
Once you’ve done that, perform the usual checks in the IDE (board selection and correct COM port) then upload to your Wemos. You should have a blinking LED!

One up from the ‘blink’ script – wiring your own LED is an easy intro to a new board.
Understanding the Sketch
Let’s quickly explain what each part is doing here:
int LED = D7;
This is giving the D7 pin a name – ‘LED’.
void setup() { pinMode(LED, OUTPUT); // Make LED pin D7 an output pin }
This is a one-time command, setting the ‘LED’ pin as an output (to ‘output’ power when we tell it to)
void loop() { digitalWrite(LED, LOW); // LED off delay(3000); // Wait 3 seconds digitalWrite(LED, HIGH); // LED on delay(1000); // Wait 1 second }
This is the loop – the main part of our program. This will keep looping over and over forever.
We tell the LED to set LOW then wait 3000 milliseconds (3 seconds) i.e. the LED should be off for 3 seconds.
It then sets the LED HIGH and waits for 1000 milliseconds (1 second) i.e. the LED should light for 1 second.
Backwards is Better
I’ve been reading up on the WeMos/ESP8266 specs, and one thing that’s worth sharing here is the GPIO limits.
It seems the GPIO pins are better used as a sink (GND) than a source (+3.3V). This is because the GPIO pins on the Wemos can sink more current (~20mA) than they can source (~12mA).
So whilst each pin can offer 12mA individually (without a board maximum to worry about), if you want the brightest LEDs or simply more current for a different project/component, turning things around could be worthwhile.
I read up on it here (which is a Node MCU thread but the ESP8266 is the same).
Now Go Play
That’s a very basic Wemos LED project but a nice gentle introduction to using the GPIO.
Perhaps try expanding with more LEDs to start with, as this comment suggests each digital pin can offer 12mA individually without any overall board limit to worry about.
After that, maybe try your hand at sinking current via the GPIO for even greater brightness.
I’ll post some more Wemos projects soon, so get subscribed and I’ll see you next time.
Rich
Be the first to comment on "Wemos LED Control"