How to use a Shift Register 74HC595
- Get link
- Other Apps
Shift Register
Introduction
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.
In this tutorial you will practice by using the shift register with Arduino uno to control 8 LEDs.
What you will need - Hardware
The Circuit
The connections are easy, see the image above with the breadboard circuit schematic.
You can find more info about IC here: datasheet |
Here's the code!
We will use example sketch from ShiftRegister74HC595.h library.
How it works:
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
The Code ::
********************************************************************************
/*
ShiftRegister74HC595.h - Library for easy control of the 74HC595 shift register.
*/
#include <ShiftRegister74HC595.h>
// create shift register object (number of shift registers, data pin, clock pin, latch pin)
ShiftRegister74HC595 sr (1, 2, 3, 4);
void setup() {
}
void loop() {
sr.setAllHigh(); // set all pins HIGH
delay(500);
sr.setAllLow(); // set all pins LOW
delay(500);
for (int i = 0; i < 8; i++) {
sr.set(i, HIGH); // set single pin HIGH
delay(2000);
}
// set all pins at once
uint8_t pinValues[] = { B10101010 };
sr.setAll(pinValues);
delay(5000);
// read pin (zero based)
uint8_t stateOfPin5 = sr.get(5);
}
********************************************************************************
Note :: Try to change line:
uint8_t pinValues[] = { B10101010 }; with uint8_t pinValues[] = { B11001100 };
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!
- Get link
- Other Apps
Atiacilviugi Jamie Jackson https://marketplace.visualstudio.com/items?itemName=urlatuhi.Angels-Of-Fasaria--Version-2-0-gratuita-2021
ReplyDeletegiftfittiti
gratin0tioma Sarah Baker https://www.bereadyfam.com/profile/Discografia-Completa-Franco-Califano-Torrent-HOT/profile
ReplyDeletedumpprevimul
provtaplannoDes Moines Joe Delic Avid Pro Tools
ReplyDeleteCamtasia Studio
ESET NOD32 Internet Security
chrisununen
Unisttuinyu Joe Bonsness Best
ReplyDeleteget
icdedere