#include #include enum flagi { W_PRAWO = 0x01, W_LEWO = 0x02, DZIALAJ = 0x04 }; int main(void) { uint8_t led = 0x00; uint8_t flags = 0x00; DDRB = 0xff; // use all pins on PortB for output DDRD = 0x00; // use all pins on port D for input PORTD = 0xff; // activate internal pull-up PORTB = 0x00; // set output high -> turn all LEDs off while (1) { // loop forever if ( flags == 0 && PIND & (W_PRAWO | W_LEWO) ) //Jest wciśnięty jeden z przycisków { flags |= PIND; } else if ( flags & (W_PRAWO | W_LEWO) //przycisk został puszczony && PIND == 0x00 && !(flags & DZIALAJ)) { flags |= DZIALAJ; if( flags & W_LEWO) led = 0x01; else led = 0x80; PORTB = led; } else if ( flags & DZIALAJ ) { if ( flags & W_LEWO && !(led & 0x80)) led <<= 1; else if(flags & W_PRAWO && !(led & 0x01)) led >>= 1; PORTB = led; } } }