- UID
- 746677
- 阅读权限
- 10
- 推广
-
- 幽默
-
- 注册时间
- 2015-4-15
- 最后登录
- 1970-1-1
|
注册家电维修技术论坛,与同行畅聊维修技术,享更多技术论坛功能。
您需要 登录 才可以下载或查看,没有帐号?快速注册
x
/*------------------------------------------------------------------------------
利用ATmeag16单片机驱动数码管显示数字,PD端口第一位驱动数码的段选,第二位驱动
数码管的位选。PA端口送入数据。
------------------------------------------------------------------------------*/
#include <iom16v.h>
#include <macros.h>
#define uchar unsigned char
uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar table_1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned int num;
void delay(void)
{
unsigned int i,j;
for(i=0;i<240;i++)
for(j=0;j<240;j++);
}
uchar read(void)
{
uchar i,j;
for(i=0;i<100;i++)
for(j=0;j<240;j++)
num++;
if(num==9999)
num=0;
return num;
}
void main(void)
{
uchar i;
DDRA=0XFF;
PORTA=0XFF;
DDRD=0XFF;
PORTA |=0X03;
while(1)
{
for(i=0;i<16;i++)
{
PORTD |=0X02; PORTA=table_1[i]; PORTD &=~0X02;
PORTD |=0X01; PORTA=table[i]; PORTD &=~0X01;
delay();
}
}
} |
|