this is my example program using parallax in atmega16.
void parallax(void)
{
start:
t=1;
DDRB.0=1;//set PORTB.0 as output n pull up
PORTB.0=1;
delay_us(5);
PORTB.0=0; //set PORT B.0 as input
DDRB.0=0;
PORTB.0=1 ;
for(i=0;i<1050;i++) //if there is no echo recive till i=1050 go to start
{
if(PINB.0==1)//recive echo
goto coun;
}
goto start;
coun:
if(PINB.0==0)
goto hitung;
t=t+1 ;
delay_us(1);
goto coun;
hitung:
s=340*1000000*t/2 //count the distance in m
delay_ms(10);
return;
}