Sketch is not working with Nano perfectly like Mega2560

Hi, I have tried by connecting 10K ohm Pull up resistor but No success :frowning: ... still the same results....

Another observation.....serial.begin (2400), I2C communication..

  1. If I upload it keeping the serial monitor open...signal appears in oscilloscope, and if I close the serial monitor, signal doesnt come in oscilloscope....

  2. If I upload it and doesnt open the serial monitor, signal appears in oscilloscope, and If I disconnect arduino and plug it in again, it doesnt show any signal on oscilloscope....but then after opening the serial monitor, signal start appearing in oscilloscope.....

  3. whenever serial monitor closed , in other words mechanism doesnt work (LED on arduino pin 13 blinks), as soon as I open the serial monitor,(or Mechanism works) it stops blinking.

in my final application, I have to connect it with the mains power supply...

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,