const int led[] ={3,5,6,9,10,11};
int i;
int j;
const int rain[12][6]=
{{250, 0, 0, 0, 0, 0},
{200,250, 0, 0, 0, 0},
{150,200,250, 0, 0, 0},
{100,150,200,250, 0, 0},
{ 50,100,150,200,250, 0},
{ 0, 50,100,150,200,250},
{ 0, 0, 50,100,150,200},
{ 0, 0, 50,100,150,200},
{ 0, 0, 0, 50,100,150},
{ 0, 0, 0, 0, 50,100},
{ 0, 0, 0, 0, 0, 50},
{ 0, 0, 0, 0, 0, 0}};
void setup()
{
}
void loop()
{
for(i=0;i<13;i++)
{
for(j=0;j<6;j++)
analogWrite(led[j],rain[i][j]);
delay(100);
}
}
例2
const int led[] ={3,5,6,9,10,11};
int i;
int j;
const int rain[19][6]=
{{250, 0, 0, 0, 0, 0},
{200,250, 0, 0, 0, 0},
{150,200,250, 0, 0, 0},
{100,150,200,250, 0, 0},
{ 50,100,150,200,250, 0},
{ 0, 50,100,150,200,250},
{ 0, 0, 50,100,150,200},
{ 0, 0, 50,100,150,200},
{ 0, 0, 0, 50,100,150},
{ 0, 0, 0, 0, 50,100},
{ 0, 0, 0, 0, 0, 50},
{ 0, 0, 0, 0, 0, 0},
{0,0,0,0,0,255},
{0,0,0,0,200,255},
{0,0,0,0,200,255},
{0,0,0,150,200,255},
{0,0,100,150,200,255},
{0,50,100,150,200,255},
{0,0,0,0,0,255},
};
void setup()
{
}
void loop()
{
for(i=0;i<19;i++)
{
for(j=0;j<6;j++)
analogWrite(led[j],rain[i][j]);
delay(100);
}
}
沒有留言:
張貼留言