图一是我画的电路图,按照设计所说左下角应该有一个灯是点亮的,下面是代码
#include<reg52.h>#include<stdio.h>sbit P0_7=P0^7;sbit P2_0=P2^0;void ys(void){unsigned int k;for(k=13000;k>0;k--){}}unsigned char keyscan(void){unsigned char cord_h,cord_l;P3=0xf0;cord_h=P3&0xf0;if(cord_h!=0xf0) {ys(); P3=0xf0; cord_h=P3&0xf0; if(cord_h!=0xf0) {cord_h=P3&0xf0; P3=cord_h|0x0f; cord_l=P3&0x0f; return(cord_h+cord_l); } }}void main(void){unsigned char key;xdata char AB[64][2]={0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF};unsigned char C[1];unsigned char D[1];int m=0,i=0,j=0,a,b;P0=0;P2=0xFF;P0_7=1;P2_0=0;C[0]=P0;D[0]=P2;
上面程序不全,限制字数,总之运行出来P0.7并没有输出高电平,左下角的灯没有亮