微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机实验板2011_V1.0 - 74HC377控制数码管显示

单片机实验板2011_V1.0 - 74HC377控制数码管显示

时间:11-18 来源:互联网 点击:

硬件原理图:

74HC377功能图:

源程序:

#include
#include
#include
#include
#include
#include

#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long

sbit A9=P2^1; //
sbit A10=P2^2; //
sbit W_R=P3^6; //
sbit LED_CS=P1^4;

//数码管取表数据0-F
uchar LED_DATA[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};

uchar LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8;//定义8个数码管显示数据存储地址空间
void delay(unsigned int count);//延时程序
void display(void); //数码管显示子程序

/*************延时子程序start**************/
void delay(unsigned int count)
{
unsigned int i,j;
for(i=0;ifor(j=0;j<50;j++);
}
/*************延时子程序end****************/

/************************/
void display(void)
{
uchar speed;//定义数码管动态扫描频率

speed=3;

P0=LED6;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xfd;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
////////////////
P0=LED5;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xfe;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
//////////////
P0=LED8;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xfb;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
/////////////
P0=LED7;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xf7;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
/////////////
P0=LED1;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xef;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
////////////
P0=LED2;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xdf;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
///////////////
P0=LED3;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0xbf;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
/////////////////
P0=LED4;
A9=0;
W_R=0;
W_R=1;
A9=1;

P0=0x7f;
A10=0;
W_R=0;
W_R=1;
A10=1;
delay(speed);
}

/***********主程序************/
main()
{
uint i;

Delay1ms(1000);

P0=0X00;
LED_CS=1;
A9=1;
A10=1;

Delay1ms(100);

//显示12345678
LED1=LED_DATA[1];
LED2=LED_DATA[2];
LED3=LED_DATA[3];
LED4=LED_DATA[4];
LED5=LED_DATA[5];
LED6=LED_DATA[6];
LED7=LED_DATA[7];
LED8=LED_DATA[8];

while(1)
{
display();
}

}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top