#include // Last modified: 26 October 2006 // Changed to work with WinAVR 20060421 // modified: 21 April 2005 // Compiled on WinAVR 20060421 //--------------------- // function prototypes void delay(void); int main(void); //--------------------- void delay(void) { uint32_t waitcounter; waitcounter = 2000; while(0 != waitcounter) { waitcounter--; } } int main(void) { uint8_t ctr; int i; //--------- // initialise the hardware DDRA = 0x03; PORTA = 0x00; DDRB = 0x1F; PORTB = 0x00; DDRD = 0x7C; PORTD = 0x00; //--------- // the main loop while(1) { for (ctr=0; ctr<8; ctr++){ for (i=0; i<300; i++) { // LED 0 // set color PORTB = ctr*4; // turn on LED PORTA |= 0x01; // the delay delay(); //turon off LED PORTA &= 0xFE; // LED 1 // set color PORTB = ((ctr+1)%8)*4; // turn on LED PORTA |= 0x02; // the delay delay(); //turon off LED PORTA &= 0xFD; // LED 2 // set color PORTB = ((ctr+2)%8)*4; // turn on LED PORTB |= 0x01; // the delay delay(); //turon off LED PORTB &= 0xFE; // LED 3 // set color PORTB = ((ctr+3)%8)*4; // turn on LED PORTB |= 0x02; // the delay delay(); //turon off LED PORTB &= 0xFD; // LED 4 // set color PORTB = ((ctr+4)%8)*4; // turn on LED PORTD |= 0x04; // the delay delay(); //turon off LED PORTD &= 0xFB; // LED 5 // set color PORTB = ((ctr+5)%8)*4; // turn on LED PORTD |= 0x08; // the delay delay(); //turon off LED PORTD &= 0xF7; // LED 6 // set color PORTB = ((ctr+6)%8)*4; // turn on LED PORTD |= 0x10; // the delay delay(); //turon off LED PORTD &= 0xEF; // LED 7 // set color PORTB = ((ctr+7)%8)*4; // turn on LED PORTD |= 0x20; // the delay delay(); //turon off LED PORTD &= 0xDF; // LED 8 // set color PORTB = ((ctr+8)%8)*4; // turn on LED PORTD |= 0x40; // the delay delay(); //turon off LED PORTD &= 0xBF; } } } //--------- }