#include <avr/io.h>
#include <util/delay.h>
void setup() {
DDRD |= (1<<0);
DDRD |= (1<<1);
DDRD |= (1<<2);
DDRB &= ~(1<<0);
DDRB &= ~(1<<1);
DDRB &= ~(1<<0);
}
int main(){
setup();
int a=0;
int b=0;
int c=0;
int x=0;
while(1){
if (PINB &(1<<0) && a==0){
a=1;
_delay_ms(500);
}
else if (PINB&(1<<0) && a==1){
a=0;
_delay_ms(500);
}
if (PINB &(1<<1) && b==0 && a==1 ){
b=1;
x=1;
c=0;
_delay_ms(500);
}
else if (PINB&(1<<1) && b==1){
b=0;
c=0;
x=0;
_delay_ms(500);
}
if (PINB &(1<<2) && c==0 && a==1 ){
c=1;
b=0;
x=2;
_delay_ms(500);
}
else if (PINB&(1<<2) && c==1 ){
c=0;
b=0;
x=0;
_delay_ms(500);
}
switch(x){
case 1:
PORTD &=~(1<<2);
_delay_ms(1000);
PORTD |=(1<<1);
break;
case 2:
PORTD &=~(1<<1);
_delay_ms(1000);
PORTD |=(1<<2);
break;
default:
if(a==1){
PORTD &=~(1<<1);
PORTD &=~(1<<2);
_delay_ms(1000);
PORTD |=(1<<0);
}
break;
}
}return;
}