according to my homework, I have designed a digital clock via 6, 7segments using 3ports of ATMEGA16. now I want to add

**push buttons**to adjust min and hour.. so I need 4push button to decrease or increase them. but I dont know what is the

**algorithm for keys**. I put the schematic and C codes of my program. any body knows how to do this?

and this is my code (without codes for keys):

Rich (BB code):

```
#include <mega16.h>
#include <delay.h>
unsigned int h,h1,m,m1,s,s1;
void main()
{
DDRA=0xff;
DDRC=0xff;
DDRD=0xff;
while(1)
{
for(h=0;h<=5;h++)
{PORTA=h<<4;
for(h1=0;h1<=9;h1++)
{
if(h==2 && h1==4) goto S1;
PORTA=(h<<4)|h1;
for(m=0;m<=5;m++)
{PORTD=m<<4;
for(m1=0;m1<=9;m1++)
{PORTD=(m<<4)|m1;
for(s=0;s<=5;s++)
{PORTC=s<<4;
for(s1=0;s1<=9;s1++)
{PORTC=(s<<4)|s1;
delay_us(100);
}
}
}
}
}
} S1:
}
}
```