AT89C51单片机C语言编程16*16点阵程序

2024年11月20日 02:41
有2个网友回答
网友(1):


#include 
unsigned char code tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};  //控制列,P2控制,低电平显示
unsigned char code digittab[10][8]={{0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00}, //0 控制行,P0控制,高电平显示,八行十个数字
{0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00}, //1
{0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00}, //2
{0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00}, //3
{0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00}, //4
{0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00}, //5
{0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00}, //6
{0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00}, //7
{0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00}, //8
{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00} //9
};

unsigned int time;
unsigned char a,b;

sbit duan=P3^6;//数码管段显示
sbit wei=P3^7;//数码管位显示

/***************************************/ 
/*          主程序                     */ 
/***************************************/
void main(void)
{
 duan=1;
 P0=0X00;
 duan=0;  //关闭数码管段显示
 wei=1;  //数码管位显示,,点阵行控制

TMOD=0x01;//初装中断值
TH0=(65536-3000)/256;
TL0=(65536-3000)%256;
TR0=1;
ET0=1;
EA=1;

while(1)
 {;}
}

/***************************************/ 
/*          中断子程序                 */ 
/***************************************/ 
void t0(void) interrupt 1 using 0   //中断
{
TH0=(65536-3000)/256;
TL0=(65536-3000)%256;
P2=tab[a]; //共阳点阵,P2控制低电平,P0控制高电平
P0=digittab[b][a]; //P0控制锁存器74HC573输出高电平控制行
  a++;
if(a==8)
{
  a=0;
}
  time++;
if(time==233)
{
  time=0;
  b++;
if(b==10)
{
  b=0;
}
}
}

网友(2):

我有成套项目和图和程序,功能上要改一下,可代你做调试好