大神们帮我看一下这个代码,普中的A2板子,数码管不能显示键码值,只能一闪而过,有什么办法可以稳定清晰的显示键码值呢?
单片机源程序如下:
#include <REGX52.H>
#include "LCD1602.h"
#include "MatrixKey.h"
#include "NixieTube.h"
unsigned char KeyNum;
void main()
{
LCD_Init();
LCD_ShowString(1,1,"MatrixKey:");
while(1)
{
KeyNum=MatrixKey();
if(KeyNum)
{
NixieTube(1,KeyNum);
NixieTube(2,KeyNum);
NixieTube(3,KeyNum);
NixieTube(4,KeyNum);
NixieTube(5,KeyNum);
NixieTube(6,KeyNum);
NixieTube(7,KeyNum);
NixieTube(8,KeyNum);
}
}
}
#include <REGX52.H>
#include <INTRINS.H>
#include "Delay1ms.h"
unsigned char code NixieTable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,
0x7d,0x07,0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x00};
void NixieTube(unsigned char Location,Number)
{
switch(Location)
{
case 1:P2_4=1;P2_3=1;P2_2=1;break;
case 2:P2_4=1;P2_3=1;P2_2=0;break;
case 3:P2_4=1;P2_3=0;P2_2=1;break;
case 4:P2_4=1;P2_3=0;P2_2=0;break;
case 5:P2_4=0;P2_3=1;P2_2=1;break;
case 6:P2_4=0;P2_3=1;P2_2=0;break;
case 7:P2_4=0;P2_3=0;P2_2=1;break;
case 8:P2_4=0;P2_3=0;P2_2=0;break;
}
P0=NixieTable[Number];
Delay1ms(1);
P0=0x00;
}
|