#include <avr/io.h>
#include <util/delay.h>
#define CW 0
#define CCW 1
int main (void) {
DDRA=0xFF;
DDRB &=~(1<<4);
PORTB |=(1<<4);
DDRH &=~(1<<4);
PORTH |=(1<<4);
PORTA=0xFF;
int arah=0;
while(1)
{
if (arah==CW) {
for(int i=0;i<=7;i++){
PORTA = ~(1<<i);
_delay_ms(200);
}
} else if (arah==CCW){
for(int i=7;i>=0;i--){
PORTA = ~(1<<i);
_delay_ms(200);
}
}
if (!(PINB&(1<<4))) {
arah=CW;
} else if (!(PINH&(1<<4))) {
arah=CCW;
}
}
}
PB4
PH6
PH5
PH4
PB7
PB6