#include "ShiftRegister74HC595.h"
// create a global shift register object
// parameters: <number of shift registers> (data pin, clock pin, latch pin)
ShiftRegister74HC595<2> sr(11, 12, 8);
int mline1[]={0,1,2,3};
byte mline2[]={4,5,6,7,8};
byte mline3[]={9,10,11,12,13,14};
int mline4[8][2]={{0,1},{4,5},{9,10},{11,12},{13,14},{7,8},{2,3},{1,2}};
int mline5[8][2]={{13,14},{7,8},{2,3},{1,2},{0,1},{4,5},{9,10},{11,12}};
//int mline6[][]={{0,14},{4,8},{9,3},{}
int kec=3;
int button=2;
int input=4;
int pot=A0;
void setup() {
Serial.begin(115200);
pinMode(kec,OUTPUT);
pinMode(button,INPUT);
pinMode(input, INPUT_PULLUP);
//setupp();
attachInterrupt(digitalPinToInterrupt(button),rem,LOW);
}
void loop() {
//while(button == LOW){rem();}
//rem();
mode_7();
//sr.updateRegisters();
}
void setBrightness(byte brightness)
{
analogWrite(kec,255-brightness);
}
int mline10[4][12]={{6},{1,2,5,7,11,12},{0,1,2,3,4,8,10,11,12,13},{0,1,2,3,4,8,9,10,11,12,13,14}};
void setupp(){
setBrightness(200);
for(int i =0; i<5;i++){sr.set(mline2[i],HIGH);}
delay(100);
for(int i =0; i<5;i++){sr.set(mline2[i],LOW);}
for(int a=0;a<1;a++){sr.set(mline10[0][a],HIGH);}
delay(500);
for(int a=0;a<1;a++){sr.set(mline10[0][a],LOW);}
for(int b=0;b<6;b++){sr.set(mline10[1][b],HIGH);}
delay(500);
for(int b=0;b<6;b++){sr.set(mline10[1][b],LOW);}
for(int c=0;c<10;c++){sr.set(mline10[2][c],HIGH);}
delay(500);
for(int c=0;c<10;c++){sr.set(mline10[2][c],LOW);}
for(int d=0;d<12;d++){sr.set(mline10[3][d],HIGH);}
delay(100);
for(int d=0;d<12;d++){sr.set(mline10[3][d],LOW);}
for(int c=0;c<10;c++){sr.set(mline10[2][c],HIGH);}
delay(100);
for(int c=0;c<10;c++){sr.set(mline10[2][c],LOW);}
for(int b=0;b<6;b++){sr.set(mline10[1][b],HIGH);}
delay(100);
for(int b=0;b<6;b++){sr.set(mline10[1][b],LOW);}
for(int a=0;a<1;a++){sr.set(mline10[0][a],HIGH);}
delay(100);
for(int a=0;a<1;a++){sr.set(mline10[0][a],LOW);}
delay(100);
}
void mode_1()
{setBrightness(100);
unsigned long tmr = millis();
static unsigned long x;
static int flag;
switch(flag){
case 0 :
for(int a=0;a<4;a++){sr.set(mline1[a],HIGH);}
break;
case 1 :
for(int a=0;a<4;a++){sr.set(mline1[a],LOW);}
break;
case 2 :
for(int b=0;b<5;b++){sr.set(mline2[b],HIGH);}
break;
case 3 :
for(int b=0;b<5;b++){sr.set(mline2[b],LOW);}
break;
case 4 :
for(int c=0;c<6;c++){sr.set(mline3[c],HIGH);}
break;
case 5 :
for(int c=0;c<6;c++){sr.set(mline3[c],LOW);}
break;
case 6 :
flag = 0;
break;
};
if(tmr - x > 100){
x = tmr;
flag++;
}
}
void mode_2()
{
setBrightness(100);
sr.set(6,HIGH);
unsigned long tmr = millis();
static unsigned long x;
static int flag;
static int counter;
switch(flag){
case 0 : //1
counter = 0;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 1 :
counter = 0;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 2 : //2
counter = 1;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 3 :
counter = 1;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 4 : //3
counter = 2;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 5 :
counter = 2;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 6 : //4
counter = 3;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 7 :
counter = 3;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 8 : //5
counter = 4;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 9 :
counter = 4;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 10 : //6
counter = 5;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 11 :
counter = 5;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 12 : //7
counter = 6;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 13 :
counter = 6;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 14 : //8
counter = 7;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],HIGH);
sr.set(mline5[counter][b],HIGH);
}
break;
case 15 :
counter = 7;
for(int b=0;b<2;b++)
{
sr.set(mline4[counter][b],LOW);
sr.set(mline5[counter][b],LOW);
}
break;
case 16 :
flag = 0;
break;
};
if(tmr - x > 100){
x = tmr;
flag++;
}
//Serial.println(String()+ "flag:"+flag);
}
void mode_3()
{
setBrightness(100);
for(int a=0;a<3;a++)
{
for(int b=0;b<16;b++)
{
sr.set(b,HIGH);
}
delay(100);
for(int b=0;b<16;b++)
{
sr.set(b,LOW);
}
delay(100);
}
delay(300);
}
int mline6[9][2]={{9,10},{10,11},{11,12},{12,13},{13,14},{12,13},{11,12},{10,11},{9,10}};
unsigned long sv=0;
unsigned long sv1=0;
unsigned long sv2=0;
int Delay=500;
int flag;
int flag1;
int fg;
void mode_4()
{
setBrightness(200);
unsigned long tmr=millis();
for(int a=0; a<4;a++){sr.set(a,HIGH);}
if(tmr-sv>Delay){
sv=tmr;
flag = !flag;
//fg++;
}
if(flag == 1 ){
if(tmr-sv2>50){
sv2 = tmr;
if(fg < 6){
fg++;
if(fg % 2 == 0){for(int i=4;i<9;i++){sr.set(i,HIGH);}}
//delayMicroseconds(1000);
else{for(int i=4;i<9;i++){sr.set(i,LOW);}}
//delayMicroseconds(1000);
//Serial.println(String()+"fg:"+fg);
}
else{fg=0;}
}
}
if(tmr-sv1>100){
sv1 = tmr;
for(int a=0;a<2;a++){
sr.set(mline6[flag1][a],HIGH);
}
for(int a=0;a<2;a++){
sr.set(mline6[flag1][a],LOW);
}
flag1++;
if(flag1 == 9){flag1=0;}
}
}
void mode_5()
{
setBrightness(200);
unsigned long tmr = millis();
static unsigned long x;
static int flag=0;
switch(flag){
case 0 :
for(int a=0;a<6;a++){sr.set(mline3[a],HIGH);}
break;
case 1 :
for(int a=0;a<6;a++){sr.set(mline3[a],LOW);}
break;
case 2 :
for(int b=0;b<5;b++){sr.set(mline2[b],HIGH);}
break;
case 3 :
for(int b=0;b<5;b++){sr.set(mline2[b],LOW);}
break;
case 4 :
for(int c=0;c<4;c++){sr.set(mline1[c],HIGH);}
break;
case 5 :
for(int c=0;c<4;c++){sr.set(mline1[c],LOW);}
break;
case 6 :
flag = 0;
break;
};
if(tmr - x > 100){
x = tmr;
flag++;
}
}
void mode_6()
{
setBrightness(200);
unsigned long tmr = millis();
static unsigned long x;
static int flag;
switch(flag){
case 0 :
for(int a=0;a<6;a++){sr.set(mline3[a],HIGH);}
for(int c=0;c<4;c++){sr.set(mline1[c],HIGH);}
for(int b=0;b<5;b++){sr.set(mline2[b],LOW);}
break;
case 1:
for(int b=0;b<5;b++){sr.set(mline2[b],HIGH);}
for(int a=0;a<6;a++){sr.set(mline3[a],LOW);}
for(int c=0;c<4;c++){sr.set(mline1[c],LOW);}
break;
case 2 :
flag=0;
break;
};
if(tmr - x > 300){
x = tmr;
flag++;
}
}
void mode_7()
{
setBrightness(200);
unsigned long tmr = millis();
static unsigned long x;
static int flag=0;
switch(flag){
case 0 :
for(int a=0;a<4;a++){sr.set(mline1[a],HIGH);}
break;
case 1 :
for(int a=0;a<4;a++){sr.set(mline1[a],LOW);}
break;
case 2 :
for(int b=0;b<5;b++){sr.set(mline2[b],HIGH);}
break;
case 3 :
for(int b=0;b<5;b++){sr.set(mline2[b],LOW);}
break;
case 4 :
for(int c=0;c<6;c++){sr.set(mline3[c],HIGH);}
break;
case 5 :
for(int c=0;c<6;c++){sr.set(mline3[c],LOW);}
break;
case 6 :
for(int a=0;a<6;a++){sr.set(mline3[a],HIGH);}
break;
case 7 :
for(int a=0;a<64;a++){sr.set(mline3[a],LOW);}
break;
case 8 :
for(int b=0;b<5;b++){sr.set(mline2[b],HIGH);}
break;
case 9 :
for(int b=0;b<5;b++){sr.set(mline2[b],LOW);}
break;
case 10 :
for(int c=0;c<4;c++){sr.set(mline1[c],HIGH);}
break;
case 11 :
for(int c=0;c<4;c++){sr.set(mline1[c],LOW);}
break;
case 12 :
flag = 0;
break;
};
if(tmr - x > 100){
x = tmr;
flag++;
}
}
void rem()
{
unsigned long tmr = millis();
static unsigned long x;
static int flag=0;
for(int i=0; i<5;i++){
if(i==0){
for(int b=0;b<4;b++){sr.set(mline1[b],LOW);}
for(int c=0;c<5;c++){sr.set(mline2[c],LOW);}
for(int d=0;d<6;d++){sr.set(mline3[d],LOW);}
}
if(i==1){
setBrightness(100);
for(int b=0;b<4;b++){sr.set(mline1[b],HIGH);}
}
if(i==2){
setBrightness(100);
for(int c=0;c<5;c++){sr.set(mline2[c],HIGH);}
}
if(i==3){
setBrightness(100);
for(int d=0;d<6;d++){sr.set(mline3[d],HIGH);}
}
if(i==4){
setBrightness(255);
for(int b=0;b<4;b++){sr.set(mline1[b],HIGH);}
for(int c=0;c<5;c++){sr.set(mline2[c],HIGH);}
for(int d=0;d<6;d++){sr.set(mline3[d],HIGH);}
}
delay(100);
}
// if(tmr - x > 100){
// x = tmr;
// if(flag < 4){flag++;}
// }
}