First, do you understand how the PING))) sensor works? If not, you need to download the documentation for it and look at it in detail.
You also have to carefully go through your C manual for the ATMega8 and make sure that your C system allows you to use the same I/O pin for both output and input (and see how to do that). You need to know how to produce a 2-5us pulse and how to time a received pulse anywhere from 115us to 18.5ms. I can't help you with those pieces. They're dependent on the ATMega8 and your C system.
Comments
You also have to carefully go through your C manual for the ATMega8 and make sure that your C system allows you to use the same I/O pin for both output and input (and see how to do that). You need to know how to produce a 2-5us pulse and how to time a received pulse anywhere from 115us to 18.5ms. I can't help you with those pieces. They're dependent on the ATMega8 and your C system.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen