矩阵键盘在数码管上显示1-16的平方,只显示个位
如题,就是我用protues仿真只显示个位数,其他不显示#include <reg52.h>#define uint unsigned int#define uchar unsigned charsbit dula=P2^6;sbit wela=P2^7;int num;uchar temp,rnum,i,bai,shi,ge,aa;uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0};uchar fanhui();void display(uchar,uchar,uchar);void delay(uint z){ uint x,y; if(x=z,x>0,x--) {if(y=110,y>0,y--);}}void main(){ uchar aa1, aa2; while(1) { aa1 = fanhui(); display(bai, shi, ge); //用显示,当延时,消抖 aa2 = fanhui(); //再读 if (aa1 == aa2) aa = aa1; //两者相等,确认到aa i = aa * aa; bai = i / 100; shi = (i % 100) / 10; ge = i % 10; display(bai, shi, ge); }} uchar fanhui(){ P3=0xfe; temp=P3; temp=temp&0xf0; while(temp!=0xf0) { dula=1; P0=0; dula=0; delay(10); temp=P3; temp=temp&0xf0; while(temp!=0xf0) { temp=P3; switch(temp) { case 0xe
更多