急求:用扫描法读出4×4矩阵键盘,在8×8LED点阵屏上点亮对应灯(用单片机89C51) 要仿真图和C程序!
展开全部
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit A = P2^5;
sbit B1 = P2^6;
sbit C = P2^7;
uchar code lie[]={1,2,4,8,16,32,64,128};
uchar code DIS1[]=
{
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xF7,0xE3,0xC1,0x80,0xE3,0xE3,0xE3,0xE3, /*箭头*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
uchar code DIS2[][8]=
{
0xC3,0xBD,0xBD,0xBD,0xBD,0xBD,0xBD,0xC3,/*"未命名文件",0*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xEF,0xE7,0xEF,0xEF,0xEF,0xC7,0xFF,/*"未命名文件",1*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xC7,0xBB,0xBF,0xBF,0xCF,0xE7,0xFB,0x83,/*"未命名文件",2*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xC7,0xBB,0xBF,0xBF,0xCF,0xBF,0xBB,0xC7,/*"未命名文件",3*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xDF,0xCF,0xD7,0xDB,0xDD,0x81,0xDF,0xDF,/*"未命名文件",4*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x83,0xFB,0xFB,0xC3,0xBF,0xBF,0xBB,0xC7,/*"未命名文件",5*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC7,0xBB,0xFB,0xC3,0xBB,0xBB,0xC7,/*"未命名文件",6*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0x83,0xBF,0xDF,0xEF,0xF7,0xF7,0xF7,/*"未命名文件",7*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC7,0xBB,0xBB,0xC7,0xBB,0xBB,0xC7,/*"未命名文件",8*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC7,0xBB,0xBB,0x87,0xBF,0xBF,0xC7,/*"未命名文件",9*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
void Delay_Ms(uchar ms)
{
uchar x,y;
for(x=0;x<ms;x++)
for(y=0;y<110;y++);
}
void display()
{
uchar i,j,k;
for(j=0;j<sizeof(DIS2);j++)
for(k=0;k<20;k++)
for(i=0;i<8;i++) //8列显示
{
A=0;B1=1;C=1;
P0 = lie[i];
A=1;B1=1;C=1;
P0 = DIS1[i+j];
Delay_Ms(15);
A=1;B1=1;C=1;
P0 = 0xff;
}
}
void main()
{
A=1;B1=0;C=1;
P0=0;
while(1)
{
display();
}
}
按键那里我们没有程序在,点阵驱动做好了加上按键就switch上去就好了!
#define uchar unsigned char
#define uint unsigned int
sbit A = P2^5;
sbit B1 = P2^6;
sbit C = P2^7;
uchar code lie[]={1,2,4,8,16,32,64,128};
uchar code DIS1[]=
{
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xF7,0xE3,0xC1,0x80,0xE3,0xE3,0xE3,0xE3, /*箭头*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
uchar code DIS2[][8]=
{
0xC3,0xBD,0xBD,0xBD,0xBD,0xBD,0xBD,0xC3,/*"未命名文件",0*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xEF,0xE7,0xEF,0xEF,0xEF,0xC7,0xFF,/*"未命名文件",1*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xC7,0xBB,0xBF,0xBF,0xCF,0xE7,0xFB,0x83,/*"未命名文件",2*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xC7,0xBB,0xBF,0xBF,0xCF,0xBF,0xBB,0xC7,/*"未命名文件",3*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xDF,0xCF,0xD7,0xDB,0xDD,0x81,0xDF,0xDF,/*"未命名文件",4*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x83,0xFB,0xFB,0xC3,0xBF,0xBF,0xBB,0xC7,/*"未命名文件",5*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC7,0xBB,0xFB,0xC3,0xBB,0xBB,0xC7,/*"未命名文件",6*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0x83,0xBF,0xDF,0xEF,0xF7,0xF7,0xF7,/*"未命名文件",7*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC7,0xBB,0xBB,0xC7,0xBB,0xBB,0xC7,/*"未命名文件",8*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC7,0xBB,0xBB,0x87,0xBF,0xBF,0xC7,/*"未命名文件",9*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
void Delay_Ms(uchar ms)
{
uchar x,y;
for(x=0;x<ms;x++)
for(y=0;y<110;y++);
}
void display()
{
uchar i,j,k;
for(j=0;j<sizeof(DIS2);j++)
for(k=0;k<20;k++)
for(i=0;i<8;i++) //8列显示
{
A=0;B1=1;C=1;
P0 = lie[i];
A=1;B1=1;C=1;
P0 = DIS1[i+j];
Delay_Ms(15);
A=1;B1=1;C=1;
P0 = 0xff;
}
}
void main()
{
A=1;B1=0;C=1;
P0=0;
while(1)
{
display();
}
}
按键那里我们没有程序在,点阵驱动做好了加上按键就switch上去就好了!
追问
按键加上去 没反应
追答
是你地按键扫描有问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询