#include <iom8535v.h>
#include <macros.h.>
#define S 50
void port_init(void)
{
PORTA=0x81; //na vhod
DDRA=0x00;
PORTB=0x00;
DDRB=0xF0; //na vihod
}
void main(void)
{
long i;
int k=1;
port_init();
while(1)
{
if (PINA&1==1 && k==1)
{
for(i=1;i<S;i++);
PORTB=PINA&128;
k=2;
}
else if(PINA&1==1 && k==2)
{
for(i=1;i<S;i++);
PORTB=PORTB|PINA>>1;
k=3;
}
else if(PINA&1==1 && k==3)
{
for(i=1;i<S;i++);
PORTB=PORTB|PINA>>2;
k=4;
}
else if(PINA&1==1 && k==4)
{
for(i=1;i<S;i++);
PORTB=PORTB|PINA>>3;
k=5;
}
}
}
I2luY2x1ZGUgPGlvbTg1MzV2Lmg+CiNpbmNsdWRlIDxtYWNyb3MuaC4+CiNkZWZpbmUgUyA1MAoKdm9pZCBwb3J0X2luaXQodm9pZCkKewpQT1JUQT0weDgxOyAvL25hIHZob2QKRERSQT0weDAwOwpQT1JUQj0weDAwOyAKRERSQj0weEYwOyAvL25hIHZpaG9kCn0KCgp2b2lkIG1haW4odm9pZCkKewpsb25nIGk7CmludCBrPTE7CnBvcnRfaW5pdCgpOwp3aGlsZSgxKQp7CmlmIChQSU5BJjE9PTEgJiYgaz09MSkKewpmb3IoaT0xO2k8UztpKyspOwpQT1JUQj1QSU5BJjEyODsKaz0yOwp9CmVsc2UgaWYoUElOQSYxPT0xICYmIGs9PTIpCnsKZm9yKGk9MTtpPFM7aSsrKTsKUE9SVEI9UE9SVEJ8UElOQT4+MTsKaz0zOwp9CmVsc2UgaWYoUElOQSYxPT0xICYmIGs9PTMpCnsKZm9yKGk9MTtpPFM7aSsrKTsKUE9SVEI9UE9SVEJ8UElOQT4+MjsKaz00Owp9CmVsc2UgaWYoUElOQSYxPT0xICYmIGs9PTQpCnsKZm9yKGk9MTtpPFM7aSsrKTsKUE9SVEI9UE9SVEJ8UElOQT4+MzsKaz01Owp9Cn0KfQo=