今天这个很好理解,大家自己就可看明白:
Proteus截图:
Atmel Studio 6.2程序:
/*
* GccApplication25.c
*
* Created: 2014-9-19 22:55:40
* Author: Administrator
*/
#include <avr/io.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char tab1[]={0x00,0x36,0x36,0x36,0x49};
unsigned char tab2[]={0x01,0x02,0x04,0x08,0x10};
void delay(uint n)
{
uint i;
for(i=0;i<n;i++);
}
int main(void)
{
uchar j,t=0;
DDRC=0xFF;
PORTC=0xFF;
DDRD=0xFF;
PORTD=0xFF;
while(1)
{
for(j=0;j<6;j++)
{
PORTD=tab2[t];
PORTC=tab1[j];
delay(555);
t++;
if(t==6)
{
t=0;
PORTD=0x00;
}
}
}
}
|