ESP8266 NodeMCU – Usinging 74HC595N Shift Register

In this tutorial, we will learn how to control a 74HC595N Shift Register. Understanding the basic working principles of the 74HC595 and its usefulness, we can now begin to apply it in our projects.

Parts Required

To build the global setup you must have the following parts:

  • ESP8266 NodeMCU v1.0;
  • • Micro-USB to USB cable;
  • 74hc595n;
  • • 8 leds;
  • • 8 x 220 ohm rasistor;
  • • Male to male jumper wires;
  • • 1 Breadboard;

Note: You do not need to have a NodeMCU board nor an ESP8266 to follow this tutorial. I am using this board because it is very famous and also because, I will post future tutorials using wifi communications. In order to use other boards, you just have to change the pin number.

Shift Register 74HC595N

Figure 1

A shift register is a circuit you can use to control many outputs (8 here) at the same time while only using a few pins (3 here) of your board. It works on Serial IN Parallel OUT protocol. It receives data serially from the microcontroller and then sends out this data through parallel pins.

Thankfully Arduino provide a helper function specifically for shift registers called shiftOut(), which allows to simply shift the bits in one call. The shiftOut() function takes four parameters; the first two are the pins to use for Data and Clock respectively. The third parameter specifies which end of the data you want to start at. We are going to start with the right most bit, which is referred to as the ‘Least Significant Bit’ (LSB).
The last parameter is the actual data to be shifted into the shift register, which in this case is a byte variable that you will fill with the respective leds you to turn on or off.

Figure 2

As you can see in figure 2, pins marked as Q0-Q7 (15 and 1-7) are the output pins. Pin16 is connected to (VCC) 3.3V, whereas pins 8 and 13 are connected to ground and pin 10 to (VCC) 3.3V. Finally pins 14, 12 and 11 are data, latch and clock pins and are the ones used by NodeMCU to pass data to the shift register.

For further understanding about the logic and function tables of this circuit, you can visit the datasheet.

Circuit

Figure 3

We will start by placing the shift register in our breadboard, ensuring that each of its sides are placed on a separate side of the breadboard.

Then, we will connect pins 16 (VCC) to the 3.3V pin on the NodeMCU and connect pins 8 (GND) to its Gnd pin. This should keep the shift register into the normal working mode.

Next, we have to connect the three pins needed to control the shift register, which, in this case, are the following:

  • Pin 11 (SRCLK) of the shift register to pin D5 on the NodeMCU;
  • Pin 12 (RCLK) of the shift register to pin D8 on the NodeMCU;
  • Pin 14 (SER) of the shift register to pin D7 on the NodeMCU.

Finally, we just have to connect all the output pins (QA-QH) to each one of our LEDs, ensuring that a 220Ω resistor is placed between the output pin and the LEDs, in order to limit the current flowing through them, and that the cathodes of the LEDs are connected to ground.

The result of the previously described wiring process should be similar to the illustration shown figure 4.

Coding

Video

To see a video of the setup working, you can visit our youtube channel and watch the video.

Please follow and like us:
Ricardo Carreira

Author: Ricardo Carreira

Portuguese Electrical Engineer interested in Automation, Energy, Power generation, Renewables and 3D printers . With a degree in Electrical and Computer Engineering in the field of Energy and Automation. Currently starting in Master’s degree in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *