This tutorial of Robo India explains how to use Shift Register HC595 on NodeMCU using Arduino IDE.
1. Introduction:
A shift register is used for serial input and converting them to parallel output. In simple language it is used to increase output pins. Because it just used three pins as input and gives 8 ouput pins.
1.1 Hardware required
S.No. | Item | Quantity | Buy on Robo India | Buy on Amazon |
1 | NodeMCU | 1 | click here | click here |
2 | Micro USB Cable | 1 | click here | click here |
3 | Shift Register Module by Robo India | 1 | click here | click here |
5 | Jumper Male to female | 5 | click here | click here |
2. Building Circuit
3. Programming:
Once the circuit part is done, NodeMCU is needed to be programmed. Here is the code to run this circuit on NodeMCU.
You may download this code (Arduino Sketch) from here.
// Robo India Tutorial on Shift Register 74HC595 const int DataPin = 2; //Data Pin is connected to Pin D4 const int LatchPin = 0; //Latch Pin is connected to Pin D3 const int ClockPin = 4; //Clock Pin is connected to Pin D2 void setup() { pinMode (DataPin, OUTPUT); pinMode (ClockPin, OUTPUT); pinMode (LatchPin, OUTPUT); } void loop() { digitalWrite (LatchPin, LOW); shiftOut(DataPin, ClockPin, LSBFIRST, 255); digitalWrite (LatchPin, HIGH); delay(1000); digitalWrite (LatchPin, LOW); shiftOut(DataPin, ClockPin, LSBFIRST, 0); digitalWrite (LatchPin, HIGH); delay(1000); }
4. Output
All 8 LEDs blink together at an interval of 1 second. Try changing values between 0-255. Convert this values to binary, the binary pattern is shown on LEDs.
5. Troubleshooting
Showing Wrong pattern: Try changing LSBFIRST/HSBFIRST in shiftout command.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com