AVR Development Board – AVR-DK20A User Manual
37
}
} while (1);
}
A.8 Tutorial 3 – 7-Segment 00-99 decimal counter
//Tutorial 3
//Title : A Decimal 7-segment display counter, count from 00 to 99
//Jumper for 7segment : LK9-LK14
//Jumper Setting: B0-A,B1-B,B2-C,B3-D,B4-DIG1,B5-DIG2
unsigned char j,g,temp1,temp2, counter1;
void main() {
DDRB = 0xff; // Set direction to be output
j=0;
g=0;
while(1)
{
for(j=0; j<=10; j++)
{
if((g>=9)&&(j>9))
{
g=0;
j=0;
}
else if (j>9)
{
j=0;
g++;
}
for(counter1=0; counter1<10; c+)
{
PORTB = 0x20;
temp1 = PORTB;
temp2 = j;
PORTB = (temp1 | temp2);
delay_ms(5);
PORTB = 0x10;
temp1 = PORTB;
temp2 = g;
PORTB = (temp1|temp2);
delay_ms(5);
}
}
}
}