Nguyên văn bởi doãn đức
Xem bài viết
chúc bạn thành công !!!
//8 led sang duoi nhau //tai 1 thoi diem chi duy nhat 1 led sang #include <REGX51.H> #define led0 P1_0 #define led1 P1_1 #define led2 P1_2 #define led3 P1_3 #define led4 P1_4 #define led5 P1_5 #define led6 P1_6 #define led7 P1_7 #define sang 1 #define tat 0 //--------------- void delay( unsigned int ms ) { unsigned int i,j; for (i=0;i<ms;i++) for (j=0;j<120;j++) {} } //-------------- void display_led(unsigned char number) { switch (number) { case 1: led0=sang; led1=led2=led3=led4=led5=led6=led7=tat; break; case 2: led1=sang; led0=led2=led3=led4=led5=led6=led7=tat; break; case 3: led2=sang; led1=led0=led3=led4=led5=led6=led7=tat; break; case 4: led3=sang; led1=led2=led0=led4=led5=led6=led7=tat; break; case 5: led4=sang; led1=led2=led3=led0=led5=led6=led7=tat; break; case 6: led5=sang; led1=led2=led3=led4=led0=led6=led7=tat; break; case 7: led6=sang; led1=led2=led3=led4=led5=led0=led7=tat; break; case 8: led7=sang; led1=led2=led3=led4=led5=led6=led0=tat; break; } } main () { unsigned char m; while(1) { for (m=0;m<8;m++) {display_led(m);delay(1000);} } }
Comment