流水灯 按照由亮变暗的模式运行

void led_breath1(int d1,int mode)
{
// int speed=1000;
int x=0;
switch(mode)
{
case 1://由暗转亮
while(x++<speed)
{
GPFDAT=0xff;
cdelay(speed-x);
GPFDAT=~(1<<(d1+3));
cdelay(x);
}
break;
case 0://灯由亮转暗
while(x++<speed)
{
GPFDAT=~(1<<(d1+3));
cdelay(speed-x);
GPFDAT=0xff;
cdelay(x);
}
break;
}
}
void led_loop2(void)
{
while(1)
{
led_breath1(1,1);
led_breath1(1,0);
led_breath1(2,1);
led_breath1(2,0);
led_breath1(3,1);
led_breath1(3,0);
led_breath1(4,1);
led_breath1(4,0);
led_breath1(3,1);
led_breath1(3,0);
led_breath1(2,1);
led_breath1(2,0);
led_breath1(1,1);
led_breath1(1,0);
}
}

你可能感兴趣的:(s3c2440,流水灯)