int datapin = 2;
int clockpin = 5;
int latchpin = 4;
byte pattern[] = {
0b00000000, // all LEDs off
0b00000001, // LED 0 on
0b00000010, // LED 1 on
0b00000100, // LED 2 on
0b00001000, // LED 3 on
0b00010000, // LED 4 on
0b00100000, // LED 5 on
0b01000000, // LED 6 on
0b10000000, // LED 7 on
};
void setup() {
pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(clockpin, OUTPUT);
}
void loop() {
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, LSBFIRST, 0b10000000);
digitalWrite(latchpin, HIGH);
delay(100);
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, LSBFIRST, 0b01000000);
digitalWrite(latchpin, HIGH);
delay(200);
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, LSBFIRST, 0b10000000);
digitalWrite(latchpin, HIGH);
delay(300);
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, LSBFIRST, 0b1000000);
digitalWrite(latchpin, HIGH);
delay(200);
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, LSBFIRST, 0b00000000);
digitalWrite(latchpin, HIGH);
delay(800);
for(int i=0;i<8;i++){
shiftOut(datapin, clockpin, MSBFIRST,pattern[i]);
digitalWrite(latchpin, HIGH);
delay(10);
digitalWrite(latchpin, LOW);
delay(50);}
digitalWrite(latchpin, LOW);
shiftOut(datapin,clockpin,MSBFIRST,0b11111111);
digitalWrite(latchpin, HIGH);
delay(1000);
digitalWrite(latchpin, LOW);
shiftOut(datapin,clockpin,LSBFIRST,0b11111111);
digitalWrite(latchpin, HIGH);
delay(50);
digitalWrite(latchpin, LOW);
shiftOut(datapin,clockpin,LSBFIRST,0b00000000);
digitalWrite(latchpin, HIGH);
delay(500);
digitalWrite(latchpin, LOW);
shiftOut(datapin,clockpin,LSBFIRST,0b11111111);
digitalWrite(latchpin, HIGH);
delay(70);
digitalWrite(latchpin, LOW);
shiftOut(datapin,clockpin,LSBFIRST,0b00000000);
digitalWrite(latchpin, HIGH);
delay(300);
}