int led[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
int min_speed=20;
int max_speed=100;
int delay_Value;
unsigned long current=0;
unsigned long old=0;
long interval=0;
void read_pot()
{
delay_Value=analogRead(A5);
delay_Value=map(delay_Value,0,1023,min_speed,max_speed);
}
void led_row(int xx, int yy)
{
for(int i=0; i<6;i++)
digitalWrite(led[i+xx*6-6],yy);
}
void led_col(int xx, int yy)
{
for(int i=0; i<3;i++)
digitalWrite(led[xx-1+i*6],yy);
}
void led_clr()
{
for(int i=0; i<18;i++)
digitalWrite(led[i],0);
}
void led_all()
{
for(int i=0; i<18;i++)
digitalWrite(led[i],1);
}
void setup()
{
for(int i=0; i<18;i++)
pinMode(led[i],OUTPUT);
pinMode(A5,INPUT);
read_pot();
}
void loop()
{
effect1();
effect2();
effect3();
effect4();
effect5();
effect6();
effect7();
effect8();
effect9();
effect10();
effect11();
effect12();
effect13();
effect14();
effect15();
effect16();
effect17();
effect18();
effect19();
effect20();
effect21();
effect22();
effect23();
effect24();
effect25();
}
void effect1()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
for(int i=0; i<18;i++)
{
digitalWrite(led[i],HIGH);
delay(delay_Value);
digitalWrite(led[i],LOW);
read_pot();
}
}
}
void effect2()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_row(1, 1);
delay(delay_Value*6);
led_row(1, 0);
led_row(2, 1);
delay(delay_Value*6);
led_row(2, 0);
led_row(3, 1);
delay(delay_Value*6);
led_row(3, 0);
delay(delay_Value*6);
}
}
void effect3()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
for(int z=1;z<7;z++)
{
led_col(z, 1);
delay(delay_Value);
led_col(z, 0);
}
}
}
void effect4()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
int r=random(1,7);
for(int z=1;z<=r;z++)
{
led_col(z, 1);
delay(delay_Value);
}
for(int z=r;z>=1; z--)
{
led_col(z, 0);
delay(delay_Value);
}
delay(delay_Value);
}
}
void effect5()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
int r=random(1,6);
for(int z=6;z>=r;z--)
{
led_col(z, 1);
delay(delay_Value);
read_pot();
}
for(int z=r;z<=6; z++)
{
led_col(z, 0);
delay(delay_Value);
read_pot();
}
delay(delay_Value);
}
}
void effect6()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_row(1,1);
led_row(2,0);
led_row(3,1);
delay(delay_Value*8);
led_row(1,0);
led_row(2,1);
led_row(3,0);
delay(delay_Value*8);
}
}
void effect7()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
int r=random(1,7);
led_col(r,1);
delay(delay_Value);
led_col(r,0);
delay(delay_Value);
}
}
void effect8()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
int r=random(1,4);
led_row(r,1);
delay(delay_Value);
led_row(r,0);
delay(delay_Value);
}
}
void effect9()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
int r=random(0,18);
for(int z=18;z>=r;z--)
{
digitalWrite(led[z],HIGH);
delay(delay_Value/3);
read_pot();
}
for(int z=r;z<=18; z++)
{
digitalWrite(led[z],LOW);
delay(delay_Value/3);
read_pot();
}
delay(delay_Value);
}
}
void effect10()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
delay(delay_Value*3);
for(int z=0;z<=8; z++)
{
digitalWrite(led[z],1);
digitalWrite(led[17-z],1);
delay(delay_Value*1);
read_pot();
}
delay(delay_Value);
}
}
void effect11()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
delay(delay_Value*3);
for(int z=8;z>=0; z--)
{
digitalWrite(led[z],1);
digitalWrite(led[17-z],1);
delay(delay_Value*1);
read_pot();
}
delay(delay_Value);
}
}
void effect12()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
delay(delay_Value*3);
for(int z=0;z<=8; z++)
{
digitalWrite(led[z],1);
digitalWrite(led[17-z],1);
delay(delay_Value*1);
digitalWrite(led[z],0);
digitalWrite(led[17-z],0);
read_pot();
}
delay(delay_Value);
for(int z=8;z>=0; z--)
{
digitalWrite(led[z],1);
digitalWrite(led[17-z],1);
delay(delay_Value*1);
read_pot();
}
delay(delay_Value);
}
}
void effect13()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
delay(delay_Value*3);
for(int z=0;z<=8; z++)
{
digitalWrite(led[z],1);
digitalWrite(led[17-z],1);
delay(delay_Value/2);
read_pot();
}
delay(delay_Value);
for(int z=8;z>=0; z--)
{
digitalWrite(led[z],1);
digitalWrite(led[17-z],1);
delay(delay_Value/2);
digitalWrite(led[z],0);
digitalWrite(led[17-z],0);
read_pot();
}
delay(delay_Value);
}
}
void effect14()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
for(int z=0;z<=18; z++)
digitalWrite(led[z],1);
for(int z=18;z>=0; z--)
{
digitalWrite(led[z],1);
delay(delay_Value/1.5);
digitalWrite(led[z],0);
read_pot();
}
delay(delay_Value);
for(int z=0;z<18; z++)
{
digitalWrite(led[z],1);
delay(delay_Value/1.5);
digitalWrite(led[z],0);
read_pot();
}
}
}
void effect15()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
for(int y=18;y>=0;y--)
for(int z=0;z<y; z++)
{
digitalWrite(led[z],1);
delay(delay_Value/2);
digitalWrite(led[z-1],0);
read_pot();
}
delay(delay_Value);
}
}
void effect16()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
for(int y=0;y<18;y++)
digitalWrite(led[y],1);
for(int z=1;z<18; z++)
{
digitalWrite(led[z],0);
digitalWrite(led[z-1],0);
delay(delay_Value*1.5);
digitalWrite(led[z-1],1);
read_pot();
}
for(int z=16;z>=0; z--)
{
digitalWrite(led[z],0);
digitalWrite(led[z+1],0);
delay(delay_Value*1.5);
digitalWrite(led[z+1],1);
read_pot();
}
}
}
void effect17()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
led_clr();
for(int z=3;z<18; z++)
{
digitalWrite(led[z],1);
digitalWrite(led[z-1],1);
digitalWrite(led[z-2],1);
digitalWrite(led[z-3],1);
delay(delay_Value/2);
digitalWrite(led[z-3],0);
read_pot();
}
for(int z=17;z>=3; z--)
{
digitalWrite(led[z],1);
digitalWrite(led[z-1],1);
digitalWrite(led[z-2],1);
digitalWrite(led[z-3],1);
delay(delay_Value/2);
digitalWrite(led[z],0);
read_pot();
}
}
}
void effect18()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
read_pot();
int r=random(0,18);
for(int z=0;z<=r;z++)
{
digitalWrite(led[z],HIGH);
delay(delay_Value/3);
read_pot();
}
for(int z=r;z>=0; z--)
{
digitalWrite(led[z],LOW);
delay(delay_Value/3);
read_pot();
}
delay(delay_Value);
}
}
void effect19()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
int count=17;
for (int z =0; z <18 ; z++)
{
led_clr();
digitalWrite(led[z],HIGH);
digitalWrite(led[count],HIGH);
delay(2);
count--;
if (count != 3)
delay(delay_Value);
}
}
}
void effect20()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
led_clr();
for (int z =0; z <8 ; z++)
digitalWrite(led[z],HIGH);
delay(delay_Value/2);
for (int z =17; z>=0 ; z--)
{
digitalWrite(led[z],HIGH);
delay(delay_Value/2);
digitalWrite(led[z],LOW);
}
delay(delay_Value*2);
}
}
void effect21()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
led_all();
int r=random(0,3);
for (int z =8; z >=r; z--)
{
digitalWrite(led[z],LOW);
digitalWrite(led[17-z],LOW);
delay(delay_Value/2);
read_pot();
}
for (int z =r; z <=8; z++)
{
digitalWrite(led[z],HIGH);
digitalWrite(led[17-z],HIGH);
delay(delay_Value/2);
read_pot();
}
}
}
void effect22()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
led_clr();
read_pot();
for( int k = 0; k<=10; k++)
{
int j= random(20,80);
led_row(1,1);
delay(j);
led_row(1,0);
delay(j);
}
for( int k = 0; k<=10; k++)
{
int j= random(20,80);
led_row(2,1);
delay(j);
led_row(2,0);
delay(j);
}
for( int k = 0; k<=10; k++)
{
int j= random(20,80);
led_row(3,1);
delay(j);
led_row(3,0);
delay(j);
}
}
}
void effect23()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
led_clr();
read_pot();
for (int z =0; z<17 ; z++)
for( int k = 0; k<=5; k++)
{
if(z!=8)
{
int j= random(20,80);
digitalWrite(led[z],HIGH);
digitalWrite(led[17-z],HIGH);
delay(j);
digitalWrite(led[z],LOW);
digitalWrite(led[17-z],LOW);
delay(j);
}
}
}
}
void effect24()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
led_clr();
read_pot();
for( int k = 0; k<=10; k++)
{
int j= random(20,80);
led_row(1,1);
led_row(3,1);
delay(j);
led_row(1,0);
led_row(3,0);
delay(j);
}
for( int k = 0; k<=10; k++)
{
int j= random(20,80);
led_row(2,1);
delay(j);
led_row(2,0);
delay(j);
}
}
}
void effect25()
{
led_clr();
current=millis();
old=current;
interval=0;
while (interval<5) // Change time value here
{
current=millis();
interval=(current-old)/1000;
led_clr();
delay(delay_Value*5);
read_pot();
for( int i = 0; i<18; i++)
{
for( int k = 0; k<=10; k++)
{
int j= random(20,40);
for( int l = 0; l<=i; l++)
digitalWrite(led[l],HIGH);
delay(j);
for( int l = 0; l<=i; l++)
digitalWrite(led[l],HIGH);
delay(j);
}
}
}
}