Skip to content

Instantly share code, notes, and snippets.

@giljr
Created May 14, 2017 17:42
Show Gist options
  • Save giljr/d8b72079bba010627aed7a767d15c367 to your computer and use it in GitHub Desktop.
Save giljr/d8b72079bba010627aed7a767d15c367 to your computer and use it in GitHub Desktop.
How Shift Register works? Page https://goo.gl/GcZxCR
const int clockPin = 9;
const int dataPin = 8;
void setup(){
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop(){
for(int i = 0; i<8; i++)
{
shiftOut(dataPin, clockPin, MSBFIRST, B00000001 << i);
delay(125);//125*8 = 1 second
}
for (int i = 0; i<8; i++){
shiftOut(dataPin, clockPin, MSBFIRST, B10000000 >> i);
delay(125);//125*8 = 1 second
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment