#include<reg51.h> sbit LED =P2^4;//位定义LED灯 sbit key=P1^6;//位定义按键 void main() { if(key==0){ LED=0; } if(key==1){ LED=1; } }