#include
#include
void kanan() //arah geral led kekanan
{
DDRD=0xff; //set pin D
int i; // i inisilisai
for (i=1 ;i<=128; i=i*2)
{
PORTD=i; // i inisilisai
_delay_ms(500);
}
}
void kiri() //arah geral led kekiri
{
DDRD=0xff; //set pin D
int i; // i inisilisai
for (i=128; i>1 ; i -=i/2)
{
PORTD=i; // i inisilisai
_delay_ms(500);
}
}
void blink()
{
unsigned char i= 0 ;
for (i=0;i<8;i++)
{
PORTD=0xff;
_delay_ms(500);
_delay_ms(500);
PORTD=0×00;
_delay_ms(500);
_delay_ms(500);
}
}
int main() // tempat beraksi
{
while(1)
{
kiri();
kanan();
_delay_ms(500);
_delay_ms(500);
blink();
_delay_ms(500);
_delay_ms(500);
kanan();
kiri();
_delay_ms(500);
_delay_ms(500);
blink();
_delay_ms(500);
_delay_ms(500);
}
return(0);
}
Thanks for info
ReplyDelete