/*
* tryDigLED.c
*
* Created: 2012-7-6 13:26:16
* Author: Administrator
*/
#include <avr/io.h>
unsigned char const dofly[16]={
0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90,
0x88,0x83,0xc6,0xa1,0x86,0x8e};//7段数码管段码表共阳
unsigned char num[10]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
//延时1ms
void delay_1ms(void)
{
unsigned int i;
for (i=1;i<(unsigned int)(1144-2);i++)
;
}
//延时nMS
void delay_ms(unsigned int n)
{
unsigned int i=0;
while(i<n)
{
delay_1ms();
i++;
}
}
int main(void)
{
unsigned char i;
DDRB=0xFF;//设置D口为输出模式
PORTB=0xFF;//置高电平
while(1)
{
for(i=0;i<10;i++)//顺序打开LED
{
PORTB=~num[i];
delay_ms(20);
}
for(i=0;i<16;i++)//顺序打开LED
{
PORTB= dofly[i];
delay_ms(20);
}
}
}