tiny13动态显示LED流水灯程序#includeavr/io.h#includeutil/delay.h#defineBIT(x)(1(x))#defineF_CPU8000000UL#defineT390#defineT_s330#defineT_ls230inti;intmain(void){DDRB=0xFF;PORTB=0x00;while(1){PORTB=0x00;for(i=0;i=4;i++){PORTB=BIT(i);_delay_ms(T);}_delay_ms(T_ls);PORTB=0x00;_delay_ms(T_s);PORTB=(BIT(0)|BIT(1));_delay_ms(T_s);PORTB=(BIT(1)|BIT(2));_delay_ms(T_s);PORTB=(BIT(2)|BIT(3));_delay_ms(T_s);PORTB=(BIT(3)|BIT(4));_delay_ms(T_s);PORTB=0x00;_delay_ms(500);PORTB=BIT(0);_delay_ms(T);PORTB=(BIT(0)|BIT(1));_delay_ms(T);PORTB=(BIT(0)|BIT(1)|BIT(2));_delay_ms(T);PORTB=(BIT(0)|BIT(1)|BIT(2)|BIT(3));_delay_ms(T);PORTB=(BIT(0)|BIT(1)|BIT(2)|BIT(3)|BIT(4));_delay_ms(T);_delay_ms(T_ls);PORTB=(BIT(0)|BIT(1)|BIT(2)|BIT(3));_delay_ms(T);PORTB=(BIT(0)|BIT(1)|BIT(2));_delay_ms(T);PORTB=(BIT(0)|BIT(1));_delay_ms(T);PORTB=BIT(0);_delay_ms(T);PORTB=0x00;_delay_ms(T_s);intnn;for(nn=1;nn=3;nn++){PORTB=(BIT(0)|BIT(4));_delay_ms(880);PORTB=(BIT(0)|BIT(4)|BIT(1));_delay_ms(T_s);PORTB=(BIT(0)|BIT(4)|BIT(2));_delay_ms(T_s);PORTB=(BIT(0)|BIT(4)|BIT(3));_delay_ms(T_s);PORTB=(BIT(0)|BIT(4));_delay_ms(T_s);PORTB=(BIT(0)|BIT(4)|BIT(3));_delay_ms(T_s);PORTB=(BIT(0)|BIT(4)|BIT(2));_delay_ms(T_s);PORTB=(BIT(0)|BIT(4)|BIT(1));_delay_ms(T_s);}intnumber;for(number=3;number;number--){PORTB=0x00;_delay_ms(T_ls);PORTB=(BIT(0)|BIT(4));_delay_ms(T);PORTB=0x00;_delay_ms(T_ls);PORTB=(BIT(0)|BIT(4));_delay_ms(T);PORTB=0x00;_delay_ms(T_ls);PORTB=(BIT(1)|BIT(3));_delay_ms(T);PORTB=0x00;_delay_ms(T_ls);PORTB=(BIT(1)|BIT(3));_delay_ms(T);}PORTB=0x00;_delay_ms(1000);PORTB=BIT(2);_delay_ms(3000);PORTB=0x00;_delay_ms(600);PORTB=(BIT(0)|BIT(1)|BIT(2)|BIT(3)|BIT(4));_delay_ms(3000);}}