int stcp_Pin = 4;
int shcp_Pin = 3;
int ds_Pin = 2;
void setup() {
pinMode(stcp_Pin, OUTPUT);
pinMode(shcp_Pin, OUTPUT);
pinMode(ds_Pin, OUTPUT);
}
void loop() {
// LED Chaser Animation 0: Bytes logic
for (int number = 0; number < 256; number++){
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, number );
digitalWrite(stcp_Pin, HIGH);
delay(300);
}
byte dataTwo = 0B00000000;
// LED Chaser Animation 1: Left to Right Turn 3 times
for (int j = 0; j < 3; j++) {
for (byte i = 0; i < 9; i++) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataTwo );
digitalWrite(stcp_Pin, HIGH);
delay(210);
dataTwo = (dataTwo << 1) | 0x01; // Shift '1' to the left
}
dataTwo = 0B00000000;
}
// LED Chaser Animation 2: Right to Left Sweep
for (int i = 0; i < 8; i++) {
byte data = 1 << i;
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, data);
digitalWrite(stcp_Pin, HIGH);
delay(200);
}
// LED Chaser Animation 3: Left to Right Sweep
for (int i = 7; i >= 0; i--) {
byte data = 1 << i;
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, data);
digitalWrite(stcp_Pin, HIGH);
delay(200);
}
// LED Chaser Animation 4: Alternating On/Off
byte dataOn = 0B10101010;
byte dataOff = 0B01010101;
for (int i = 0; i < 4; i++) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataOn);
digitalWrite(stcp_Pin, HIGH);
delay(200);
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataOff);
digitalWrite(stcp_Pin, HIGH);
delay(200);
}
// LED Chaser Animation 5: Bouncing LEDs
byte dataBounce = 0B00000001;
for (int i = 0; i < 7; i++) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataBounce);
digitalWrite(stcp_Pin, HIGH);
delay(200);
dataBounce <<= 1;
}
for (int i = 7; i > 0; i--) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataBounce);
digitalWrite(stcp_Pin, HIGH);
delay(200);
dataBounce >>= 1;
}
// LED Chaser Animation 6: Random LEDs
for (int i = 0; i < 8; i++) {
byte dataRandom = random(256); // Generate a random byte
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataRandom);
digitalWrite(stcp_Pin, HIGH);
delay(300);
}
// LED Chaser Animation 7: Circular Rotation
for (int i = 0; i < 8; i++) {
byte dataRotate = 1 << i;
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataRotate);
digitalWrite(stcp_Pin, HIGH);
delay(150);
}
// LED Chaser Animation 8: Morse Code "SOS" in LEDs
byte dataS = 0B01010100;
byte dataO = 0B01111100;
for (int i = 0; i < 3; i++) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataS);
digitalWrite(stcp_Pin, HIGH);
delay(500);
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataO);
digitalWrite(stcp_Pin, HIGH);
delay(500);
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataS);
digitalWrite(stcp_Pin, HIGH);
delay(500);
}
// LED Chaser Animation with Color Pattern
for (int i = 0; i < 8; i++) {
byte data = 0B00000000;
if (i < 3) {
// Green LEDs
data = 0B00000111 << (3 - i);
} else if (i < 6) {
// Yellow LEDs
data = 0B00111000 >> (i - 3);
} else {
// Red LEDs
data = 0B11000000;
}
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, data);
digitalWrite(stcp_Pin, HIGH);
delay(200);
}
// LED Chaser Animation 10: Knight Rider-Style
byte dataRider = 0B00000001;
for (int i = 0; i < 8; i++) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataRider);
digitalWrite(stcp_Pin, HIGH);
delay(100);
dataRider <<= 1;
}
for (int i = 6; i > 0; i--) {
digitalWrite(stcp_Pin, LOW);
shiftOut(ds_Pin, shcp_Pin, LSBFIRST, dataRider);
digitalWrite(stcp_Pin, HIGH);
delay(100);
dataRider >>= 1;
}
}