int datapin = 2;
int clockpin = 3;
int latchpin = 4;
byte data = 0;
void setup()
{
pinMode(datapin, OUTPUT);
pinMode(clockpin, OUTPUT);
pinMode(latchpin, OUTPUT);
}
void loop()
{
//oneAfterAnother(); // All on, all off
// oneOnAtATime(); // Scroll down the line
// pingPong(); // Like above, but back and forth
// randomLED(); // Blink random LEDs
// marquee();
binaryCount(); // Bit patterns from 0 to 255
}
void shiftWrite(int desiredPin, boolean desiredState){
bitWrite(data,desiredPin,desiredState); //Change desired bit to 0 or 1 in "data"
shiftOut(datapin, clockpin, MSBFIRST, data); //Send "data" to the shift register
digitalWrite(latchpin, HIGH);
digitalWrite(latchpin, LOW);
}
void binaryCount()
{
int delayTime = 1000; // time (milliseconds) to pause between LEDs
shiftOut(datapin, clockpin, MSBFIRST, data);
digitalWrite(latchpin, HIGH);
digitalWrite(latchpin, LOW);
data++;
delay(delayTime);
}