硬件电路图和题目;
LED1-LD8是 P2口8个管脚
mian.c
#include<reg52.h>sbit But1=P3^1 ;
sbit But2=P3^0 ;
sbit But3=P3^2 ;
sbit But4=P3^3 ;sbit LED1 =P2^0 ;
sbit LED2 =P2^1 ;
sbit LED3 =P2^2 ;
sbit LED4 =P2^3 ;#define PRESS_1 1
#define PRESS_2 2
#define PRESS_3 3
#define PRESS_4 4
#define UNPRESS_0 0typedef unsigned int u16;
typedef unsigned char u8;void delay_10us(u16 n)
{while(n--);
}press_scan(u8 mode)
{int key=1;if(key=1||(But1==0||But2==0||But3==0||But4==0)){key=0;delay_10us(500) ;if(But1==0){mode=PRESS_1;}if(But2==0){mode=PRESS_2