#define DATA_PIN 8 // Pin connected to DS of 74HC595 and D8 of Arduino
#define LATCH_PIN 9 // Pin connected to STCP of 74HC595 and D9 of Arduino
#define CLOCK_PIN 10 // Pin connected to SHCP of 74HC595 and D10 of Arduino
// How many shift registers
#define NUM_SHIFT_REGS 8
#define true HIGH
#define false LOW
const uint8_t numOfRegisterPins = NUM_SHIFT_REGS * 8;
bool registers[numOfRegisterPins];
void SR_Init() {
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
clearRegisters();
writeRegisters();
}
bool toggle = false;
void clearRegisters() {
// Reset all register pins
for (int i = numOfRegisterPins; i >= 0; i--) {
registers[i] = LOW;
}
}
void setRegisterPin(int index, int value) {
// Set an individual pin HIGH or LOW
registers[index] = value;
}
void writeRegisters() {
// Set and display registers
digitalWrite(LATCH_PIN, LOW);
for (int i = numOfRegisterPins; i >= 0; i--) {
digitalWrite(CLOCK_PIN, LOW);
digitalWrite(DATA_PIN, registers[i]);
digitalWrite(CLOCK_PIN, HIGH);
}
digitalWrite(LATCH_PIN, HIGH);
}
void write(int pinNumber, bool mode)
{
registers[pinNumber] = mode;
writeRegisters();
}
void setup() {
SR_Init();
}
void loop() {
innerBlue();
innerOrange();
pinklawan();
yellow();
innerGreen();
fread();
indigo();
innerBlue();
yellow();
outsideBlue();
outsideOrange();
yellow();
innerOrange();
outsideGreen();
}
void innerBlue() {
for (int x=0; x<57; x=x+1){
write(x,HIGH);
delay(20);
}
for (int x=0; x<=57; x=x+1){
write(x,LOW);
delay(10);
}
for (int x=0; x<=57; x=x+1){
write(x,HIGH);
delay(0);
}
for (int x=0; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
for (int x=28; x<=57; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=28; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
for (int x=4; x>=57; x=x+1){
write(x,HIGH);
delay(5);
}
for (int x=25; x<=57; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=25; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
write(0,HIGH);
write(1,HIGH);
write(2,HIGH);
write(3,HIGH);
write(0,LOW);
write(1,LOW);
write(2,LOW);
write(3,LOW);
}
void outsideBlue() {
for (int x=0; x<=57; x=x+1){
write(x,HIGH);
delay(0);
}
for (int x=0; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
write(4,HIGH);
write(5,HIGH);
write(6,HIGH);
write(7,HIGH);
write(4,LOW);
write(5,LOW);
write(6,LOW);
write(7,LOW);
}
void innerOrange() {
for (int x=4; x<57; x=x+1){
write(x,HIGH);
delay(15);
}
for (int x=0; x<=57; x=x+1){
write(x,LOW);
delay(50);
}
for (int x=2; x>57; x=x-2){
write(x,HIGH);
delay(15);
}
for (int x=2; x>=57; x=x-2){
write(x,LOW);
delay(10);
}
for (int x=2; x<=57; x=x+1){
write(x,HIGH);
delay(15);
}
write(8,HIGH);
write(9,HIGH);
write(10,HIGH);
write(11,HIGH);
write(8,LOW);
write(9,LOW);
write(10,LOW);
write(11,LOW);
}
void pinklawan() {
for (int x=12; x>=15; x=x+1){
write(x,HIGH);
delay(0.3);
}
for (int x=12; x>=15; x=x-1){
write(x,LOW);
delay(0.3);
}
for (int x=12; x>=15; x=x+1){
write(x,HIGH);
delay(5);
}
for (int x=1; x<=57; x=x+1){
write(x,LOW);
delay(0.3);
}
write(12,HIGH);
write(13,HIGH);
write(14,HIGH);
write(15,HIGH);
write(12,LOW);
write(13,LOW);
write(14,LOW);
write(15,LOW);
}
void fread() {
for (int x=2; x<57; x=x+1){
write(x,HIGH);
delay(20);
}
for (int x=2; x<=57; x=x+1){
write(x,LOW);
delay(10);
}
for (int x=2; x>=57; x=x-1){
write(x,HIGH);
delay(0);
}
for (int x=2; x>57; x=x-2){
write(x,HIGH);
delay(15);
}
for (int x=2; x>=56; x=x-2){
write(x,LOW);
delay(10);
}
for (int x=2; x<=57; x=x+1){
write(x,HIGH);
delay(15);
}
write(16,HIGH);
write(17,HIGH);
write(18,HIGH);
write(19,HIGH);
write(20,HIGH);
write(21,HIGH);
write(22,HIGH);
write(23,HIGH);
write(16,LOW);
write(17,LOW);
write(18,LOW);
write(19,LOW);
write(20,LOW);
write(21,LOW);
write(22,LOW);
write(23,LOW);
}
void innerGreen() {
for (int x=0; x<57; x=x+1){
write(x,HIGH);
delay(0.3);
}
for (int x=0; x<=57; x=x+1){
write(x,LOW);
delay(0.3);
}
for (int x=0; x<=57; x=x+1){
write(x,HIGH);
delay(0.3);
}
write(24,HIGH);
write(25,HIGH);
write(26,HIGH);
write(27,HIGH);
write(24,LOW);
write(25,LOW);
write(26,LOW);
write(27,LOW);
}
void outsideGreen() {
for (int x=2; x>57; x=x-2){
write(x,HIGH);
delay(15);
}
for (int x=2; x>=57; x=x-2){
write(x,LOW);
delay(10);
}
for (int x=2; x<=57; x=x+1){
write(x,HIGH);
delay(15);
}
write(28,HIGH);
write(29,HIGH);
write(30,HIGH);
write(31,HIGH);
write(32,HIGH);
write(33,HIGH);
write(34,HIGH);
write(35,HIGH);
write(28,LOW);
write(29,LOW);
write(30,LOW);
write(31,LOW);
write(32,LOW);
write(33,LOW);
write(34,LOW);
write(35,LOW);
}
void indigo() {
for (int x=36; x<43; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=36; x<=43; x=x+1){
write(x,LOW);
delay(10);
}
for (int x=36; x<=43; x=x+1){
write(x,HIGH);
delay(0);
}
for (int x=36; x<=43; x=x+1){
write(x,LOW);
delay(0);
}
for (int x=36; x<=43; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=36; x<=43; x=x+1){
write(x,LOW);
delay(0);
}
for (int x=36; x>=57; x=x+1){
write(x,HIGH);
delay(5);
}
for (int x=36; x<=57; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=36; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
write(36,HIGH);
write(37,HIGH);
write(38,HIGH);
write(39,HIGH);
write(40,HIGH);
write(41,HIGH);
write(42,HIGH);
write(43,HIGH);
write(36,LOW);
write(37,LOW);
write(38,LOW);
write(39,LOW);
write(40,LOW);
write(41,LOW);
write(42,LOW);
write(43,LOW);
}
void yellow() {
for (int x=43; x<=47; x=x+1){
write(x,HIGH);
delay(0.3);
}
for (int x=43; x<=47; x=x+1){
write(x,LOW);
delay(0.3);
}
for (int x=43; x>=47; x=x-1){
write(x,HIGH);
delay(0.3);
}
for (int x=10; x<=57; x=x+1){
write(x,HIGH);
delay(0.3);
}
for (int x=10; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
write(44,HIGH);
write(45,HIGH);
write(46,HIGH);
write(47,HIGH);
write(44,LOW);
write(45,LOW);
write(46,LOW);
write(47,LOW);
}
void outsideOrange() {
for (int x=28; x<=57; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=28; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
for (int x=4; x>=57; x=x+1){
write(x,HIGH);
delay(5);
}
for (int x=25; x<=57; x=x+1){
write(x,HIGH);
delay(10);
}
for (int x=25; x<=57; x=x+1){
write(x,LOW);
delay(0);
}
for (int x=0; x<=57; x=x+1){
write(x,HIGH);
delay(50);
}
for (int x=0; x<=57; x=x+1){
write(x,LOW);
delay(50);
}
for (int x=0; x>=57; x=x-1){
write(x,HIGH);
delay(50);
}
for (int x=0; x>=57; x=x-1){
write(x,LOW);
delay(50);
}
write(48,HIGH);
write(49,HIGH);
write(50,HIGH);
write(51,HIGH);
write(52,HIGH);
write(53,HIGH);
write(54,HIGH);
write(55,HIGH);
write(56,HIGH);
write(48,LOW);
write(49,LOW);
write(50,LOW);
write(51,LOW);
write(52,LOW);
write(53,LOW);
write(54,LOW);
write(55,LOW);
write(56,LOW);
}
void onlyone() {
for (int x=57; x>=57; x=x+1){
write(x,LOW);
delay(0.3);
}
write(57,HIGH);
delay(0);
}