and i have used XL- MaxSonar®- AEL0™ (MB1360) (an ultrasonic device)
Do you have a link to the datasheet of the sensor?
Can you post the code you have so far?
But i'm having trouble in interfacing it to Atmega168
What did you try? What did you expect, what did you get? Can you be more specific? i'm having trouble understanding

I also need the codes to be burnt using an Arduino board.
What do you mean?
I'm asking these questions to get a better understanding of your problem. The more info you can give the better help you can expect.