AT89C51单片机C语言编程16*16点阵程序 5
P0,P2口控制列,P1,P3口控制行!共阳的求一段c语言程序,“深圳我爱你”每个字出现一秒,然后一直循环可以的话附上说明谢谢急用!!!!...
P0,P2口控制列,P1,P3口控制行!共阳的
求一段c语言程序,“深圳我爱你”每个字出现一秒,然后一直循环
可以的话附上说明谢谢
急用!!!! 展开
求一段c语言程序,“深圳我爱你”每个字出现一秒,然后一直循环
可以的话附上说明谢谢
急用!!!! 展开
2个回答
展开全部
#include <reg52.h>
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;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询