在數(shù)碼管動態(tài)顯示中,延時時間長了數(shù)碼管不能正確顯示,咋回事呢?
程序如下:
/*******************-*******************
數(shù)碼管顯示1
2012年5月12日
**************************************/
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code d1[] = {0xf9,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0}; //字碼0-7 數(shù)碼管共陽
uchar code d2[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
/********************************************************/
void delay(void) //延時
{
uchar i,j;
for(i = 0 ; i < 1; i++)
for(j = 0 ; j < 600 ; j++); //時間調(diào)短,可以顯示出0-7,如果長了就能顯示一個了(現(xiàn)在就只有一個數(shù)碼管顯示)
}
/*****************************************************/
void main()
{
uchar i;
P0 = 0xff;
P2 = 0xff;
while(1)
{
for(i = 0 ; i < 8 ; i++) //循環(huán)點(diǎn)亮
{
P0 = d1;
P2 = d2;
delay();
P0=0xff;
}
}
}
當(dāng)延時時間長了就不能正確顯示:0-7了,只有一個數(shù)碼管亮,不知道是咋回事。求好心人給幫忙看看,謝謝。
歡迎光臨 (http://www.raoushi.com/bbs/) | Powered by Discuz! X3.1 |