book11:
这样写的按键调光功能。亮度增加和亮度减少,有问题吗?#includetypedefunsignedcharU8;typedefunsignedint U16;#definePORT_2P2U8i,i1;sbitP32=P3^2;sbitP35=P3^5;voiddelay1(U16a){ U16t; t=a;while(t--);}voidanjian() { if(P32==0) { delay1(500); if(P32==0) { i1=i1+17; if(i1==255) i1=0; } while(!P32); delay1(500); while(!P32); } if(P35==0) { delay1(500); if(P35==0) { i1=i1-17; if(i1==-1) { i1=255; } } while(!P35); delay1(500); while(!P35); } }voidmain(){PORT_2=0X00; i1=17;while(1){ anjian();for(i=0;i