本程序的原理图:
源程序:
/*
* shumaguan1.c
*
* Created: 2011-6-24 20:45:16
* Author: ZYIN
*/
#include
char temp;
int i,h,num,k;
unsigned char led0[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,
0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
void delay(void)
{
unsigned int j;
j=1000;
while(j--);
}
int main(void)
{
DDRF=0xff;
PORTF=0b00000110;
DDRA=0xff;
DDRC=0xff;
while(1)
{
for(k=0;k<45;k++)
{
temp=0b00000001;
for(i=0;i<8;i++)
{
num=i+h;
PORTA=temp;
PORTC=~led0[num];
delay();
temp<<=1;
}
}
h++;
if(h==24)
h=0;
}
}
效果图: