Introduction: How to Use a Shift Register - Arduino Tutorial

In this tutorial you will learn how to use a shift register (or serial to paralled controller). The shift register will give to your Arduino an additional 8 digital outputs, by using only 3 pins on your board

In this tutorial you will practice by using the shift register with Arduino uno to control 8 LEDs.

So, let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • Shift Register IC (74HC595)
  • 4x Red LEDs
  • 4x Green LEDs
  • 8x 330 Ohm (or 220) resistors

Step 2: The Circuit

The connections are easy, see the image above with the breadboard circuit schematic.

You can find more info about IC here: datasheet

Step 3: The Code

Here's the code, embedded using codebender!

We will use example sketch from ShiftRegister74HC595.h library.

How it works:

  • sr.setAllHight(); Turn all LEDs on
  • sr.setAllLow(); Turn all LEDs off
  • sr.set(i, HIGH); Turn LED i on ( 0 < i < 7)
  • uint8_t pinValues[] = { B10101010 };
    sr.setAll(pinValues); Binary to turn on 2nd,4th,6th and 8th LED

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board!

You can make your own modifications to the code by clicking the "Edit" button. For example, try to change line: uint8_t pinValues[] = { B10101010 }; with uint8_t pinValues[] = { B11001100 };

Step 4: Well Done!

You have successfully completed one more "How to" tutorial and you learned how to use a shift register ic with Arduino.

I hope you liked this, let me know in the comments.

You can also post photos with your circuit ;)

There will be more of them, so make sure to click Follow button!

Comments

author
dvillanueva5 (author)2017-05-22

any substitute for 74hc595?

author
violethaze (author)2017-01-05

Wiring of the green LED connected to pin 15 on shift register is wrong. The other end of the resistor should be connected to the green LED's positive not the negative side.

author
Rob van Staalduinen (author)2015-12-26

This kind of instructables makes working with Arduino easy. Thanks.

author
murilo.ferrazdealmeida (author)2015-07-22

Excelente, muito facil de intender

author
wilsondm (author)2015-07-14

gostei muito do tutorial simples fácil de aplicar,muito bom.

author
tomatoskins (author)2015-07-14

I love how handy shift registers are!

About This Instructable

12,149views

362favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: