Project tutorial
Arduino 74hc595 Shift Register With 18 eflects

Arduino 74hc595 Shift Register With 18 eflects © CC BY

Arduino 16 LEDs 18 Effects With 74hc595.

  • 2,475 views
  • 1 comment
  • 12 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
×1
74hc595 ic
×1

Apps and online services

About this project

Hello again,

I am thinking about how to control more than 20 led with Arduino Uno because Arduino Uno only has 13 digital pins. So how It's possible? That's why I came with the shift register 74hc595. We need only 3 Arduino digital pins to control LEDs using 74hc595 shift registers. There are 3 part of shift register tutorial.

Control 8 leds.Control leds brightness. Control 2 shiftRegister with led effects. I will explain coding too. Visit my website for more tutorials.

Step 1: Let Gathering the Component to Build the Arduino 74hc595 Led Chaser.

1. Arduino Uno to the control shift register.

2. Two shift registers 74hc595 for controlling the LEDs.

3. 16 LEDs as an output.

4. 16 resistors to protect the LEDs.

5. Breadboards to build the circuit on it.

6. Jumper wires for connection.

If you want to learn how shift register work? Click on this Link

Step 2: Let's Build the Circuit to Control 8 Led With Arduino and 74hc595

Pin connection:

Let's build the led chaser.

First, pick up the breadboard and connect both sides of the breadboard with the jumper wire it will used to power the shift register.

After that, attach the LEDs one by one and make sure that the led GND pin is connected to the ground side of the breadboard and, also don't forget to add a 220 ohms resistor to protect the led from high current.

Now attach the shift register on a breadboard.

Next, connect shift register pin 16 to 5v.

Next, connect shift register pin 8 to GND.

Next, connect shift register pin 10 to 5v.

Next, connect shift register pin 13 to GND.

Now we have to connect shiftRegister to Arduino so connect shiftRegister pin 11 to Arduino digital pin 2.

Connect shiftRegister pin 12 to Arduino digital pin 3.

Connect shiftRegister pin 14 to Arduino digital pin 4.

After that, connect the output pin of shiftRegister to the LEDs.

Connect ShiftRegister pin 15 to LEDs 1.

Connect ShiftRegister pin 1 to LEDs 2.

Connect all the LEDs one by one up to ShiftRegister pin 7.

After that, connect the positive side of the breadboard to the Arduino 5v pin.

Next, connect the negative side of the breadboard to the Arduino GND pin.

Now the circuit is complete let jump to the coding part.

Open the Arduino IDE.

Plug your Arduino into your computer and upload the code.

int clockPin = 2;
int latchPin = 3;
int dataPin = 4;
byte leds = 0;
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop() {
leds = 0;
updateShiftRegisterR();
delay(100);
for (int i = 0; i < 8; i++){
bitSet(leds, i);
updateShiftRegisterR();
delay(100);
}
leds = 0;
updateShiftRegisterL();
delay(100);
for (int i = 0; i < 8; i++){
bitSet(leds, i);
updateShiftRegisterL();
delay(100);
}
}
void updateShiftRegisterL(){
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}
void updateShiftRegisterR(){
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}

Step 4: Coding Explanation.

First, we have to define the controller pin of the shiftRegister.

clock pin is connected to Arduino pin 2.

The latch is connected to Arduino pin 3.

The data pin is connected to Arduino pin 4.

byte leds = 0; Its hold the location of led is turned on or off.

In void setup() now Set all pins of shiftRegister as OUTPUT

In void loop() LEDs = 0 Mean all the led is off.

updateShiftRegisterR(); This function is used to update the shiftRegister we define below.

First, we have to set the latch pin low means No update.

After that call, the Arduino function shiftOut().

Shifts out a byte of LEDs one bit at a time to the serial data pin after the clock pin goes high to low and the led bit is store in shiftRegister.

Set the order of bits LSB FIRST (Least Significant Bit) Mean we want to start turn on the LEDs from the right direction. MSBFIRST (Most Significant Bit) Mean we want to start turn on the LEDs from the left.

Now we have a location of which led is turn on so set the latch pin high means to update the outputs.

Wait for half a second. for loop to count from 0 to 7.

bitSet(); Its Arduino function to Sets a bit of particular LEDs at the location I too high.

Now update the ShiftRegister and wait a half sec.

The process is repeating, and one by one led is turned on.

Now upload the code.

The led is start turning on from the Right to left direction.

Step 5: Arduino 74hc595 Led Brightness.

There is a way to control the led brightness.

We can send the PWM signal to the shift register OE pin via Arduino PWM pin.

Remove the jumper wire from shift register pin 13 and Connect shiftRegister pin 13 to Arduino PWM pin 5.

Step 6: Coding.

int clockPin = 13; 
int latchPin = 12;
int dataPin = 10;
int outputEnablePin = 11;

byte leds = 0;

void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(outputEnablePin, OUTPUT);
}
void loop()
{
leds = 0B1111111111111111;
updateShiftRegister();
delay(500);
for (byte b = 255; b > 0; b--){
analogWrite(outputEnablePin, b);
delay(10);
}
}
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}

Step 7: Coding Explanation:

The code is a little bit the same.

Define the OE pin is connected to Arduino pin 5.

In void setup() now Set the OE pins as OUTPUT.

In void loop() Set all the led as high or turn on.

Update the shiftRegister and Wait a half sec.

In for loop count from 255 to 0

analogWrite() function is used to send the PWM signal into OE for controlling the led brightness.

Upload the code Now you will see the led brightness is increasing.

Step 8: Control 16 Leds With 18 Effects.

All the connections are the same as before the change is we are using two shift registers.

Connect the power connection to other breadboards. Add extra 8 LEDs and resistors of 220 ohms. Now attach a shiftRegister and connect the power connection same as the first one.

Next, connect shiftRegister pin 14 to pin 9.

Connect shiftRegister pin 13 to 13.

Connect shiftRegister pin 12 to 12.

Connect shiftRegister pin 11 to 11.

After that, connect the Arduino to shiftRegister.

Arduino pin 2 is connected to shiftRegister pin 11.

Arduino pin 3 is connected to shiftRegister pin 12.

Arduino pin 4 is connected to shiftRegister pin 14.

Arduino pin 5 is connected to shiftRegister pin 13.

Now, deliver the 5v to the breadboard via an Arduino.

Next connect the output pin to leds

Connect your arduino into the computer and upload the code.

Now enjoy the effects.

Step 10: Watch This Arduino 74hc595 Tutorial.


Code

Comments

Similar projects you might like

Digital Clock with Arduino, RTC and Shift Register 74HC595

Project showcase by LAGSILVA

  • 48,912 views
  • 36 comments
  • 98 respects

74HC595 Shift Register Tutorial | Arduino with 7 segment

Project tutorial by Common9899 and Akarsh Agarwal

  • 6,332 views
  • 0 comments
  • 5 respects

4 Wire LCD Control with BL and Contrast Using Shift Register

Project showcase by Mike Kowalski

  • 4,558 views
  • 3 comments
  • 11 respects

Working with Shift Register

by SUMAN BARGAV R

  • 11,250 views
  • 4 comments
  • 12 respects

Shift Register Tutorial

Project tutorial by mdraber

  • 4,157 views
  • 0 comments
  • 4 respects

How to Configure NeoPixels Using Vixen Lights and Arduino

Project tutorial by Victor Aguilar

  • 56,596 views
  • 44 comments
  • 87 respects
Add projectSign up / Login