您的位置 首页 制造

单片机试验板2011_V1.0 – 74HC377操控数码管显现

硬件原理图:74HC377功能图:源程序:#includereg52.h>#includeSTC_Delay.h>#includestdio.h>#includestdlib.h&g

硬件原理图:
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();
}

}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/zhizao/267265.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部