Arduino basics 04 - wire your own led

What if you want more than just one led - or dont like the colour?

Kurt Schoenhoff

Schematics and Wiring Diagrams

How you will connect the components



Electronic schematics or circuit diagram are a symbolic representation of an electronic circuit. It is used to show the electrical connections between the components and is usually not the same as the physical layout, although there may be similarities.

Often the components graphical representation can give clues as to its function and not usually an indication of how the component looks in real life.

For example the resistors pictured on the right of the picture made up of a zig-zag type path indicate that it is harder for the electricity to flow through them.

The Light Emitting Diode's (LED's) have arrows representing the light they give off when current flows, they also use the basic diode symbol (triangle and a bar) that indicate current can only flow in one direction.

The NodeMCU V1.0 has been given a generic rectangle this is commonly done for items or groups of items that have many pins. It also alleviates the need for creating a new symbol for every microchip that is invented


NodeMCU Multi-LED schematic

Wiring diagrams

Wiring diagrams are also graphical representations of the electrical connection and components of a circuit, however this time it is usually how you would physically lay out the circuit, or at least an approximation.

A more accurate image or physical representation for components is usually used and usually wires are colour coded to make it easier to trace then through the circuit.

In the image on the left you can see the multi LED circuit from above laid out on breadboard ready for assembly.

the NodeMCU is very similar to how it looks in real life and the resistors show their colour codes which allow easy identification.


NodeMCU - MultiLED Fritzing wiring diagram.


How to gain ultimate control over your MCU.



original sketch by ESP8266 Blink by Simon Peter

Modified by

for schematics and wiring diagram see link.


const int LED_01 = 16; // map the pins so LED_01 is on D0

const int LED_02 = 5; // map the pins so LED_02 is on D1

const int LED_03 = 4; // map the pins so LED_03 is on D2

const int LED_04 = 0; // map the pins so LED_04 is on D3

void setup() {

pinMode(LED_01, OUTPUT); // Initialize the LED_01 pin as an output

pinMode(LED_02, OUTPUT); // Initialize the LED_02 pin as an output

pinMode(LED_03, OUTPUT); // Initialize the LED_03 pin as an output

pinMode(LED_04, OUTPUT); // Initialize the LED_04 pin as an output

digitalWrite(LED_01, HIGH); // make sure all leds start in the "OFF" state

digitalWrite(LED_02, HIGH); // make sure all leds start in the "OFF" state

digitalWrite(LED_03, HIGH); // make sure all leds start in the "OFF" state

digitalWrite(LED_04, HIGH); // make sure all leds start in the "OFF" state


// the loop function runs over and over again forever

void loop() {

digitalWrite(LED_01, LOW); // Turn the LED on (Note that LOW is the voltage level

// but actually the LED is on; this is because

// it is acive low on the ESP-01)

delay(1000); // Wait for a second

digitalWrite(LED_01, HIGH); // Turn the LED off by making the voltage HIGH

digitalWrite(LED_02, LOW); // Now for LED_02


digitalWrite(LED_02, HIGH);

digitalWrite(LED_03, LOW); // Now LED_03


digitalWrite(LED_03, HIGH);

digitalWrite(LED_04, LOW); // Now the last LED


digitalWrite(LED_04, HIGH);


The code

The code has been modified from the original Blink sketch to control more LED's. The version here is designed for use on a NodeMCU ( or other ESP2866 based board). If you wish to use on an ordinary Arduino please attach the LEDs to the number set for the pin, or conversely you could re-map the pins. i.e.

int LED_01 = 0;

int LED_02 = 1;

int LED_03 = 2;

int LED_04 = 3;

void setup()

To prevent the board starting with all the LEDs on we write each LED high during the setup() function which is run once when the board starts up.

void loop()

This is the main core of the program and will be started again once it has finished, over and over, and over......... Until you power down the device or upload some more code to it.

Completed breadboard

Completed Breadboard including NodeMCU, LED's, Resistors and breadboard.

Demonstration video


Code - a more in depth look

Don't you want to know what is going on in there...

 This takes the pin we specify which is GPIO16 otherwise known as DO and puts the pin at the positive voltage for our circuit. Because the other end of the LED's is also connected to the positive rail there is no overall potential difference and therefore no flow of electrons.

If we were to set the pin top LOW then there would be a potential difference as one end of the LED (via resistor) is a the positive voltage and the other is at ground (for most simple circuits GND and negative voltage are the same) this makes a 5v difference and electrons begin to flow. The resistor slows them down so we do not burn out the LED and the LED shines.

It is important that only low current devices are connected directly to the MCU pins as they can be destroyed by large currents. DO NOT ATTACH MOTORS directly to pins not only do they most likely use to much current but they also generate spikes and transients that could fry your MCU. 


Arduino Basics 03 - Upload your code.




Arduino basics 05 - Button Input