Created
September 14, 2018 06:42
-
-
Save elktros/7accb234a28b5f12a68db27091a57992 to your computer and use it in GitHub Desktop.
Code for Interfacing 74HC595 Shift Register with Arduino.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int latchPin = 5; | |
int clkPin = 6; | |
int dataPin = 4; | |
byte LED = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(latchPin, OUTPUT); | |
pinMode(dataPin, OUTPUT); | |
pinMode(clkPin, OUTPUT); | |
} | |
void loop() | |
{ | |
int i=0; | |
LED = 0; | |
shiftLED(); | |
delay(500); | |
for (i = 0; i < 8; i++) | |
{ | |
bitSet(LED, i); | |
Serial.println(LED); | |
shiftLED(); | |
delay(500); | |
} | |
} | |
void shiftLED() | |
{ | |
digitalWrite(latchPin, LOW); | |
shiftOut(dataPin, clkPin, MSBFIRST, LED); | |
digitalWrite(latchPin, HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment