Face on a graphics Display
The code runs at a clock frequency of 8 MHz. The controller is programmed using STK500 in ISP programming mode.
void check(void)
{
TIFR0 = 1<<TOV0;
TCNT0 = 255-125;
TCCR0B = 1<<CS00|1<<CS01;
count = 0;
freq = 0;
stop_check=0;
while(count<200)
{
while((PINA&(1<<4))&&(stop_check==0))
while((!(PINA&(1<<4)))&&(stop_check==0))
if(PINA&(1<<4))
{
freq++;
}
}
freq = freq*5;
if(freq>=1900)
face = 9;
else if(freq>=1700)
face = 7;
else if(freq>=1500)
face = 6;
else if(freq>=1200)
face = 1;
else if(freq>=900)
face = 0;
else if(freq>=650)
face = 5;
else if(freq>=350)
face = 2;
else if(freq>=200)
face = 4;
else if(freq<200)
face = 3;
TCCR0B = 0x00; //stop timer
}
This is the function that measures the frequency of the input signal on the PA4 pin. It initializes Timer0 in such a way that its overflow interrupt occurs every 1 ms. ISR for Timer0 increments a variable count till 200. During this interval, each logic change on the PA4 pin is recorded in the variable freq. This is then multiplied by 5 to get the number of logical changes in 1 second and, it gives the frequency of the input signal. Using this frequency, a particular face number is assigned to the face variable. This assignment has been done using a trial-and-error process. The function putface uses this variable to display the desired face on the LCD by extracting the display bytes from the program memory of the microcontroller. It also displays blinking eyes by calling the puteye function.
The code runs at a clock frequency of 8 MHz. The controller is programmed using STK500 in ISP programming mode.
void check(void)
{
TIFR0 = 1<<TOV0;
TCNT0 = 255-125;
TCCR0B = 1<<CS00|1<<CS01;
count = 0;
freq = 0;
stop_check=0;
while(count<200)
{
while((PINA&(1<<4))&&(stop_check==0))
while((!(PINA&(1<<4)))&&(stop_check==0))
if(PINA&(1<<4))
{
freq++;
}
}
freq = freq*5;
if(freq>=1900)
face = 9;
else if(freq>=1700)
face = 7;
else if(freq>=1500)
face = 6;
else if(freq>=1200)
face = 1;
else if(freq>=900)
face = 0;
else if(freq>=650)
face = 5;
else if(freq>=350)
face = 2;
else if(freq>=200)
face = 4;
else if(freq<200)
face = 3;
TCCR0B = 0x00; //stop timer
}
This is the function that measures the frequency of the input signal on the PA4 pin. It initializes Timer0 in such a way that its overflow interrupt occurs every 1 ms. ISR for Timer0 increments a variable count till 200. During this interval, each logic change on the PA4 pin is recorded in the variable freq. This is then multiplied by 5 to get the number of logical changes in 1 second and, it gives the frequency of the input signal. Using this frequency, a particular face number is assigned to the face variable. This assignment has been done using a trial-and-error process. The function putface uses this variable to display the desired face on the LCD by extracting the display bytes from the program memory of the microcontroller. It also displays blinking eyes by calling the puteye function.
thats cool project,i also wanted to do same thing,but i didn't have nokia lcd so i used this link 16x2lcd animation
ReplyDeletehmm..good one..
ReplyDelete