#include <avr/io.h>
#include <u
til/delay.h>
int main(void)
{
int i,j;
i=0;
j=0;
PORTA=0xFF;
DDRA=0xff;
PORTC=0xFF;
DDRC=0xff;
PORTD=0xFF;
PORTD=0xc0;
DDRD=0x3f;
while(1)
{
if(!(PIND&(1<<PD6)))
{_delay_ms(2);
if(!(PIND&(1<<PD6)))
{while(!(PIND&(1<<PD6)));
i++;}
}
if(!(PIND&(1<<PD7)))
{_delay_ms(2);
if(!(PIND&(1<<PD7)))
{while(!(PIND&(1<<PD7)));
j++;}
}
switch(10*(i%3)+(j%2))
{
case 0:
PORTC&=~(1<<5);
break;
case 1:
PORTA&=~(1<<6);
break;
case 10:
PORTA&=~(1<<5);
break;
case 11:
PORTC&=~(1<<6);
break;
case 20:
PORTA&=~(1<<2);
break;
case 21:
PORTC&=~(1<<3);
break;
default:
break;
}}
}
一周热门 更多>