Created
May 14, 2017 17:44
-
-
Save giljr/9e697a42be1b779f497ca4d0db94d463 to your computer and use it in GitHub Desktop.
How Shift Register Works? page: https://goo.gl/GcZxCR
This file contains hidden or 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
const int clockPin = 9; //Clock sequence | |
const int dataPin = 8; //Serial data line | |
const int latchPin = 10; //Latch Pin | |
void setup(){ | |
pinMode(clockPin, OUTPUT); | |
pinMode(dataPin, OUTPUT); | |
pinMode(latchPin, OUTPUT); | |
} | |
void loop(){ | |
for(int i = 0; i<8; i++) | |
{ | |
shiftOut(dataPin, clockPin, MSBFIRST, B00000001 << i); | |
digitalWrite(latchPin, HIGH); | |
delay(200);//125*8 = 1 second | |
digitalWrite(latchPin, LOW); | |
} | |
for (int j = 0; j<8; j++) | |
{ | |
shiftOut(dataPin, clockPin, MSBFIRST, B10000000 >> j); | |
digitalWrite(latchPin, HIGH); | |
delay(200);//125*8 = 1 second | |
digitalWrite(latchPin, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment