|
发表于 2009-10-26 13:52:09
|
显示全部楼层
#include <avr/io.h>
unsigned char data[] = { 4, 5, 1, 9, 8, 10, 2, 6 };
int point;
void
step (int count,int delay)
{
int i;
if (count >= 0)
{
while (count > 0)
{
PORTB = data[point];
point++;
if (point >= 8)
point = 0;
count--;
for (i=0;i<delay;i++);
}
}
else
{
while (count < 0)
{
PORTB = data[point];
point--;
if (point <= 0)
point = 7;
count++;
for (i=0;i<delay;i++);
}
}
}
main ()
{
unsigned i, j, led = 0;
DDRB = 0xff;
while (1)
{
for(i=50;i<500;i+=10)
{step(50,i);
step(-50,i);}
}
} |
|