VirtualWire Program freeze error

In my code, I’m using both the libraries (NewPing.h and VirtualWire.h).

But when I upload and run my code, the program looping freezes after 4 loops and stops working (it simply sits idle).

When I remove the VirtualWire related declarations, the code works fine.

Kindly help me out :sob:

//Program might have more Serial.print statements, so take it easy.

PID_IFS__RF_IMP.ino (8.37 KB)

VirtualWire takes over use of some hardware:

"Caution: VirtualWire takes over Arduino Timer1, and this will affect the PWM capabilities of the digital pins 9 and 10."

What is NewPing.h using?

Thank u sir, Let me check it out.

Your response did me a big favor, I just changed the pins and the code works great. It's all about timer1. I changed the PWM pins from 11,12 to 2,3.

Thank you again.