#include <reg52.h>
typedef unsigned char uint8;
sbit DB0 = P1^0;
void main()
{
unsigned char i,k,p,t,j;
char l;
unsigned char a[]={0,1,2,4,6,16,32,64}; //亮度数组以实现拖尾效果
unsigned char b[]={0,34,48,59,68,76,84,91,97,103,109,114,119,123,126}; //时间数组以实现加速效果
signed char c[]={-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7};
P1=0xFF;
while(1)
{
//水滴形成(渐变效果)
k=0;
for(i=0;i<=252;i++)
{
if(0==(i%4)) k++;
for(t=0;t<=16;t++)
{
DB0=0;
for(j=0;j<=64;j++)
if(j==k) DB0=1;
}
}
//水滴掉下(加速与拖尾效果)/////////从这里开始看不懂了
for(j=0;j<=254;j++)
{
p=0;
for(k=0;k<=15;k++)
{if(j==b[k]) l=c[k];}
for(i=0;i<=64;i++)
{
for(k=0;k<=7;k++)
{
if(i==a[k])
{
p=p|(1<<k);
t=~p;
if(l>=0)
P1=~(t<<l);
else
P1=~(t>>-l);
}
}
}
}
}
}
|