Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 1000000UL // 1 MHz
- //#define F_CPU 14.7456E6
- #include <util/delay.h>
- #include <avr/io.h>
- void delay_ms( int ms)
- {
- volatile long unsigned int i;
- for(i=0;i<ms;i++)
- _delay_ms(1);
- }
- int main(void)
- {
- //ustalenie kierunku pinow
- DDRB=0xFF;
- DDRC=0xFF;
- DDRD=0xFF;
- //zdefiniowanie zmiennej odpowiadajacej za opoznienia
- int ms=250;
- int i=0;
- //ustawienie stanu poczatkowego portu
- PORTB=~(0xFF);
- PORTC=0x00;
- PORTD=0x00;
- //"biegajace" diody
- while(1){
- PORTC=0x00;
- PORTD=0x00;
- for(int j=0; j<10; j++){
- //PORTC+=1;
- //PORTC=0xFF>>(10-j);
- for(i=j;i<10;i++){
- delay_ms(ms);
- //PORTC=(PORTC<<i)+0x20;
- /*if(i<=5)
- PORTC=c+(0x20>>(5-i));
- else
- PORTC=c;
- if(i>=6)
- PORTD=d+(0x08>>(9-i));
- else
- PORTD=d;*/
- }
- if(j<=3)
- PORTD+=(0x01<<3-j);
- if(j>=4)
- PORTC+=(0x01<<9-j);
- _delay_ms(ms);
- }
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement