大佬看看还能改进吗,感觉有点麻烦
程序代码:
#include <reg51.h> sbit key=P3^0; void delay10ms(unsigned char i) { int n,p; for(n=0;n<i;n++) for(p=0;p<200;p++); } void main() { P2=0xa0;P0=0x00;P2=0; P2=0x80; while(1) { unsigned int i; if(key==0) { for(i=0;i<9;i++) { P0=0xFF<<i; delay10ms(100); } for(i=0;i<7;i++) {P0=0xFF; P0=0xFF<<(7-i); delay10ms(100); } } else if(key==1) { P0=0x7F; delay10ms(100); P0=0x3F; delay10ms(100); P0=0x9F; delay10ms(100); P0=0xCF; delay10ms(100); P0=0xEF; delay10ms(100); P0=0xF3; delay10ms(100); P0=0xF9; delay10ms(100); P0=0xFC; delay10ms(100); P0=0xFE; delay10ms(100); P0=0xFF; delay10ms(100); } } }[local]1[/local]