#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
const unsigned char display_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90};
unsigned char num=0;
int main()
{
EICRA=0X02;
EIMSK=0X01;
sei();
DDRC=0xff;
DDRD=0XFC;
PORTD=0X03;
while(1)
{
PORTC=display_code[num];
}
}
SIGNAL(SIG_INTERRUPT0)
{
_delay_ms(10);
num++;
if(num==10)
num=0;
}
用Atmega128写的,有一个警告,proteus仿真时数码管只显示1,按键时不发生改变 |