按下16个矩阵键盘依次在数码管上显示1-16的平方.如按下第一个显示1,第二个显示4...#include #define uchar unsigned char#define uint unsigned intuchar b,bai,shi,ge;uchar const el[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/31 02:49:49
![按下16个矩阵键盘依次在数码管上显示1-16的平方.如按下第一个显示1,第二个显示4...#include #define uchar unsigned char#define uint unsigned intuchar b,bai,shi,ge;uchar const el[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7](/uploads/image/z/8925039-63-9.jpg?t=%E6%8C%89%E4%B8%8B16%E4%B8%AA%E7%9F%A9%E9%98%B5%E9%94%AE%E7%9B%98%E4%BE%9D%E6%AC%A1%E5%9C%A8%E6%95%B0%E7%A0%81%E7%AE%A1%E4%B8%8A%E6%98%BE%E7%A4%BA1-16%E7%9A%84%E5%B9%B3%E6%96%B9.%E5%A6%82%E6%8C%89%E4%B8%8B%E7%AC%AC%E4%B8%80%E4%B8%AA%E6%98%BE%E7%A4%BA1%2C%E7%AC%AC%E4%BA%8C%E4%B8%AA%E6%98%BE%E7%A4%BA4...%23include+%23define+uchar+unsigned+char%23define+uint+unsigned+intuchar+b%2Cbai%2Cshi%2Cge%3Buchar+const+el%5B%5D%3D%7B0x3f%2C0x06%2C0x5b%2C0x4f%2C0x66%2C0x6d%2C0x7d%2C0x07%2C0x7)
按下16个矩阵键盘依次在数码管上显示1-16的平方.如按下第一个显示1,第二个显示4...#include #define uchar unsigned char#define uint unsigned intuchar b,bai,shi,ge;uchar const el[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7
按下16个矩阵键盘依次在数码管上显示1-16的平方.如按下第一个显示1,第二个显示4...
#include
#define uchar unsigned char
#define uint unsigned int
uchar b,bai,shi,ge;
uchar const el[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,
\x09\x09 \x09 0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar keycan(void);
void delay(uint z);
void display(uchar bai,uchar shi,uchar ge);
void main()
{
uchar key;
P0=0x00;
while(1)
{
\x09key=keycan();
\x09switch(key)
\x09{
\x09 case 0xee:b=1*1; break;
\x09 case 0xde:b=2*2; break;
\x09 case 0xbe:b=3*3; break;
\x09 case 0x7e:b=4*4; break;
\x09 case 0xed:b=5*5; break;
\x09 case 0xdd:b=6*6; break;
\x09 case 0xbd:b=7*7; break;
\x09\x09 case 0x7d:b=8*8; break;
\x09\x09 case 0xeb:b=9*9; break;
\x09\x09 case 0xdb:b=10*10; break;
\x09\x09 case 0xbb:b=11*11; break;
\x09\x09 case 0x7b:b=12*12; break;
\x09\x09 case 0xe7:b=13*13; break;
\x09\x09 case 0xd7:b=14*14; break;
\x09 case 0xb7:b=15*15; break;
\x09\x09 case 0x77:b=16*16; break;
\x09}
\x09 bai=b/100;
\x09 shi=b%100/10;
\x09 ge=b%10;
\x09 display(bai,shi,ge);
}
}
uchar keycan()
{
uchar cord_h,cord_l;
P3=0x0f;
cord_h=P3&0x0f;
if(cord_h!=0x0f)
{
delay(100);
\x09cord_h=P3&0x0f;
\x09if(cord_h!=0x0f)
\x09{
\x09 P3=cord_h|0xf0;
\x09 cord_l=P3&0xf0;
\x09 return(cord_h+cord_l);
\x09}
}return (0xff); \x09
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar bai,uchar shi,uchar ge)
{
P2=0;\x09
P0=el[bai];
delay(10);
P2=1;
P0=el[shi];
delay(10);
P2=2;
P0=el[ge];
delay(10);
}
谁能告诉我的程序错在哪了啊 我怎么就调试不出来呢
按下16个矩阵键盘依次在数码管上显示1-16的平方.如按下第一个显示1,第二个显示4...#include #define uchar unsigned char#define uint unsigned intuchar b,bai,shi,ge;uchar const el[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7
#include
#define uchar unsigned char
#define uint unsigned int
uchar b,bai,shi,ge;
uchar const table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x76,0x79,0x38,0x00};
sbit dula=P2^6;
sbit wela=P2^7;
uchar keycan(void);
void delay(uint z);
void display(uchar bai,uchar shi,uchar ge);
void main()
{
uchar key;
P0=0x00;
while(1)
{
\x05key=keycan();
\x05switch(key)
\x05{
\x05 case 0xee:b=1*1; break;
\x05 case 0xde:b=2*2; break;
\x05 case 0xbe:b=3*3; break;
\x05 case 0x7e:b=4*4; break;
\x05 case 0xed:b=5*5; break;
\x05 case 0xdd:b=6*6; break;
\x05 case 0xbd:b=7*7; break;
\x05\x05 case 0x7d:b=8*8; break;
\x05\x05 case 0xeb:b=9*9; break;
\x05\x05 case 0xdb:b=10*10; break;
\x05\x05 case 0xbb:b=11*11; break;
\x05\x05 case 0x7b:b=12*12; break;
\x05\x05 case 0xe7:b=13*13; break;
\x05\x05 case 0xd7:b=14*14; break;
\x05 case 0xb7:b=15*15; break;
\x05\x05 case 0x77:b=16*16; break;
\x05}
\x05 bai=b/100;
\x05 shi=b%100/10;
\x05 ge=b%10;
\x05 display(bai,shi,ge);
}
}
uchar keycan()
{
uchar cord_h,cord_l;
P3=0x0f;
cord_h=P3&0x0f;
if(cord_h!=0x0f)
{
delay(100);
\x05cord_h=P3&0x0f;
\x05if(cord_h!=0x0f)
\x05{
\x05 P3=cord_h|0xf0;
\x05 cord_l=P3&0xf0;
\x05 return(cord_h+cord_l);
\x05}
}return (0xff); \x05
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar bai,uchar shi,uchar ge)
{
dula=1;
\x05\x05 P0=table[bai];
\x05\x05 dula=0;
\x05\x05 P0=0xff;
\x05\x05 wela=1;
\x05\x05 P0=0xf7;
\x05\x05 wela=0;
\x05\x05 delay(1);
dula=1;
\x05\x05 P0=table[shi];
\x05\x05 dula=0;
\x05\x05 P0=0xff;
\x05\x05 wela=1;
\x05\x05 P0=0xef;
\x05\x05 wela=0;
\x05\x05 delay(1);
dula=1;
\x05\x05 P0=table[ge];
\x05\x05 dula=0;
\x05\x05 P0=0xff;
\x05\x05 wela=1;
\x05\x05 P0=0xdf;
\x05\x05 wela=0;
\x05\x05 delay(1);
}
我认为是你的void display(uchar bai,uchar shi,uchar ge)这里有错误,上面是我的程序,只是改了一点,我的好用,你的显示程序外围我不知道,
能不能把reg52.h这个头文件发出来看一下这是我的这个单片机的数码管的电路图 , 我的单片机的数码管那里就是多了一个译码器,这个程序就是最后一列按键的数16,64,144,256 在数码上显示不出来,这四个数总是在按下按键后一闪而过,其他的数都能很好的显示,我不知道是什么原因,可以帮帮我吗...
全部展开
能不能把reg52.h这个头文件发出来看一下
收起
再写不出再来找我吧
u百度地图