|
#include<reg52.h>
#define SMG_SEG P3 //這里錯(cuò)了
#define SMG_GPIO P2 //這里也錯(cuò)了
unsigned char code SEG[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code GPIO[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char DisplayData[2];
void DigDisplay()
{
unsigned char i;
unsigned int j;
for(i=0;i<2;i++)
{
SMG_GPIO = GPIO;
SMG_SEG = DisplayData;
j=50000; //延時(shí)要加大才能看到變化
while(j--);
SMG_SEG =0x00;
}
}
void Display() //這段代碼其實(shí)可以與上面的合并
{
DisplayData[0] = SEG[0];
DisplayData[1] = SEG[1];
DigDisplay();
}
void main()
{
while(1)
{
Display();
}
} |
|