generation of 40kHz square wave using PWM

msdt:
Can i generate 40kHz square wave using PWM of Arduino??

Ken Sharriff's excellent IRremote library has a function that can create and modulate a 40 KHz square wave on Arduino pin 3 (using Timer 2) for driving an IR LED to talk to IR Remote devices.

If your application is something else, you still might benefit from looking at the code to see how he does it.

Regards,

Dave