You are on page 1of 2

#include<mega16.

h>
#include<delay.h>
signed int z=0;
int a=0;
int b=0;
char led_array[10]={0x3f,0x06,0x5b,0xcf,0x66,0x6d,0x7d,0x07,0xff,0x6f};
interrupt[EXT_INT0]void EXT_int0_isr(void)
{a=1;
}
interrupt[EXT_INT1]void EXT_INT_isr(void)
{b=1;}
void main(void)
{DDRA=0xff;
PORTA=0x00;
MCUCR=0x0C;
GICR=0xc0;
DDRB=0xff;
PORTB=0x00;
# asm("sei")
PORTA=led_array[z];
while(1)
{
if(a==1)
{delay_ms(200);
if(b==1)

{z++;
PORTA=led_array[z];
a=0;b=0;}}
if(b==1)
{delay_ms(200);
if(a==1)
{z--;
PORTA=led_array[z];
a=0;b=0;}}
if(z>=9)
{PORTB=0x01;
z=9;
}
else if(z<9)
{PORTB=0x02; }if(a<0){a=0;}
}}

You might also like