我在P1_7接个按键到地,程序意图是让单片机不停扫描P1口,当按键按下时(P1^7=0)P0口输出0X00,否则,P0口输出0X44.现在是不论我按不按按键,输出都是0X00. #include<reg52.h> #include<intrins.h> #define uint unsigned int #define uchar unsigned char sbit P1_4=P1^4; sbit P1_5=P1^5; sbit P1_6=P1^6; sbit P1_7=P1^7; void delay(uint delaytime) { uint i; for(;delaytime>0;delaytime--) { for(i=0;i<124;i++) {;} } } void main() { P1=0xff; for(;;) { if( P1_7==0) { P0=0X00; delay(3000); } else P0=0x44; } } |