999 counter Video on Youtube
C code on AVR microcontroller (ATmega8515L)
#include<mega8515.h>
void loopDelay(unsigned int n)
{
while (n > 0)
{
n--;
}
}
static unsigned char SEVEN_SEG[] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};
unsigned int counter = 0x00;
unsigned int k = 0;
void main(void)
{
DDRA = 0xFF; //Set all pin as O/P
DDRE = 0x07;
PORTE = 0x07; // LED-on, BUZZ-off
DDRC = 0x07;
while (1)
{
if (counter > 999) counter = 0x00;
for (k=0;k<100;k++)
{
PORTA = SEVEN_SEG[counter/100];
PORTC = 0x04;
loopDelay(100);
PORTA = SEVEN_SEG[(counter%100)/10];
PORTC = 0x02;
loopDelay(100);
PORTA = SEVEN_SEG[counter%10];
PORTC = 0x01;
loopDelay(100);
}
counter ++;
}
}