#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); //--------------------- //this function does nothing for about 1/20th of a second. //a variable is set to 50000 and then counted down to zero. void delay(void) { uint32_t waitcounter; waitcounter = 50000; while(0 != waitcounter) { waitcounter--; } } int main(void) { uint8_t countval; int i; //--------- // initialise the hardware DDRB = 0xff; //sets port b (pins 12 through 19) to be output PORTB = 0X0f; //the initial value on port b //--------- // initialise the count value countval = 0; //--------- // the main loop while(1) { // the delay delay(); // broadcasting the binary value of countval across portb while // countval counts from 0 to 255 over and over. PORTB = countval; countval++; if(countval>=255) countval = 0; } //--------- }