This is a atmega128 source to make a clock using the
timer interrupt. I want to add source if i press switch
(PIND==0x0FE&&PIND==0x0FD) then below program would be
running .
#include<io.h>
int
position=0,BJT[4]={0xFE,0xFD,0xFB,0xF7};
int
number=0,segment[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
int msec=0, sec=0, min=0;
void main()
{
DDRA=0xFF;
PORTA=0XFF;
DDRB=0xFF;
PORTB=0xFF;
TCCR0=0x04;
TIMSK=0x01;
SREG=0x80;
while(1){}
}
interrupt[TIM0_OVF]void timer0_ovf_isr()
{
TCNT0=0x06;
PORTA=BJT[position];
if(position==0)number=sec%10;
if(position==1)number=sec/10;
if(position==2)number=min%10;
if(postion==3)number=min/10;
PORTB=segment[number];
position++;
if(position>3)position=0;
msec++;
if(msec==1000)
{
msec=0;
sec++;
}
if(sec==60)
{
sec=0;
min++;
}
if(min==60)min=0;
}