Sketch is not working with Nano perfectly like Mega2560

Hello again,

Finally my code is working properly even if I close the serial monitor. I have disabled the Serial.begin from the program and now it works almost fine.

Can anyone please tell me what affects the Serial.monitor is having on the micro-controller ?

The only problem at a moment I am having is, The sensor doesn't work (on oscilloscope, Data signal appears only half and not full ) when I swipe my hand too close (less than 5 centimeter) to the sensor.
but if I keep the serial Monitor open even if I have disabled the Serial.begin , it works perfectly even I swipe my hand below close to the sensor. So I really want to know what effect serial monitor is having on arduino nano...To make the sensor work again, I have to press RESET button on the nano board.

Is it auto resetting the Microcontroller all the time?

Thanks,