#include <REGX52.H>
void Timer1Init(void);
unsigned int fen=0;miao=0,opq=0;
void Delay(unsigned int xms);
void panduan(unsigned char n);
unsigned char code SMG_duanma[16]=
{0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x80,0xC6,0xC0,0x86,0x8E}; 数组从0-F
void Init_HC138(unsigned char n) 38译码器,控制对应Yn的口
{
switch(n) // 4,5,6,7分别开启的是4个对应的锁存器
{
case 4 : P2=(P2 & 0x1F) | 0x80; break;
case 5 : P2=(P2 & 0x1F) | 0xA0; break;
case 6 : P2=(P2 & 0x1F) | 0xC0; break;
case 7 : P2=(P2 & 0x1F) | 0xE0; break;
}
}
void showSMG_(unsigned dat)
{
Init_HC138(6); //数码管的位置
P0=0x01;
Init_HC138(7); //数码管的内容
P0=dat;
}<