#include
void delay(unsigned int i)
{
while(i)
{i=i-1;
}
}
#pragma interrupt_handler Timer1_ovf:10
void Timer1_ovf(void)
{
TCNT1H = 0xff; //reload counter high value
TCNT1L = 0x23; //reload counter low value
PORTC^=0x03;
delay(100);
}
void initial(void)
{
unsigned char sreg;
SREG=0x80;//使能全局中断
DDRA=0x00;
PORTA=0x00;
DDRC=0xFF;
PORTC=0xFF;
DDRD=0xFF;
PORTD=0xFF;
TIMSK|=(1<
TCCR1B=0x01; //无分频
TCNT1H=0xff;
TCNT1L=0x23;
}
int main(void)
{
initial();
while(1)
{
if((PINA&0x20)==0)
{
PORTC=0x0b;
PORTD=0x70;
}
else
{
PORTC=0x0f;
PORTD=0xf0;
}
}
return (0);
}