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;
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 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();
}
void effect1()
{
for(int i=0; i<18;i++)
{
digitalWrite(led[i],HIGH);
delay(delay_Value);
digitalWrite(led[i],LOW);
read_pot();
}
}
void effect2()
{
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()
{
read_pot();
for(int z=1;z<7;z++)
{
led_col(z, 1);
delay(delay_Value);
led_col(z, 0);
}
}
void effect4()
{
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()
{
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()
{
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()
{
read_pot();
int r=random(1,7);
led_col(r,1);
delay(delay_Value);
led_col(r,0);
delay(delay_Value);
}
void effect8()
{
read_pot();
int r=random(1,4);
led_row(r,1);
delay(delay_Value);
led_row(r,0);
delay(delay_Value);
}
void effect9()
{
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()
{
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()
{
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()
{
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()
{
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()
{
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()
{
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()
{
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()
{
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()
{
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);
}