вот рабочий код на attiny13
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
bool last_press = true;
int counter = 0;
int main(void) {
DDRB |= (1 << 1) | (1 << 0);// led на 0 и 1 пины подключить лампочки
DDRB &= ~(1 << 4);//key тактовая кнопка .одним концом к минусу питания другим к 4 пину
PORTB |= (1 << 4);
PORTB &= ~(1 << 1) & ~(1 << 0);
while(1) {
bool press = PINB & (1 << 4);
if(last_press && !press) {
_delay_ms(5);
press = PINB & (1 << 4);
if(!press) {
counter++;
}
}
last_press = press;
switch(counter) {
case 0:
PORTB |= (1 << 0);
PORTB &= ~(1 << 1);
break;
case 1:
PORTB |= (1 << 1);
PORTB &= ~(1 << 0);
break;
case 2:
PORTB |= (1 << 0);
PORTB |= (1 << 1);
break;
case 3:
PORTB &= ~(1 << 0);
PORTB &= ~(1 << 1);
break;
case 4:
counter = 0;
break;
}
}
}