The Ultrasonic transmitter (transducer) is effectively a capacitor and when you supply a voltage in one direction, it gets charged.
You must now supply a voltage in the opposite direction to fully discharge it and charge it in the opposite direction. This is how you will get the greatest output. If you drive it with a transistor, you need a resistor across the device to discharge it. That's why push-pull is the best method.
load the 16-bit timer1 with below values and you will get 40khz pwm.
frequency may be slightly more or less then 40khz. to get exact 40khz just adjust Icr1l......................Thats it. Tccr1a = &B10100010
Tccr1b = &B00011001
Icr1h = &H00
Icr1l = &HC7