新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)實(shí)驗(yàn)板2011_V1.0 - 74HC377控制數(shù)碼管顯示

單片機(jī)實(shí)驗(yàn)板2011_V1.0 - 74HC377控制數(shù)碼管顯示

作者: 時(shí)間:2016-11-18 來(lái)源:網(wǎng)絡(luò) 收藏

硬件原理圖:
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;
//數(shù)碼管取表數(shù)據(jù)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個(gè)數(shù)碼管顯示數(shù)據(jù)存儲(chǔ)地址空間
void delay(unsigned int count);//延時(shí)程序
void display(void); //數(shù)碼管顯示子程序

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

/************************/
void display(void)
{
uchar speed;//定義數(shù)碼管動(dòng)態(tài)掃描頻率
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();
}

}


評(píng)論


技術(shù)專區(qū)

關(guān)閉