Arduino Auto Reset: Disable and Enable at run time
Modern Arduinos have a Auto Reset circuit: There is a 0.1uF capacitor between the #DTR (not DTR) pin of the USB/UART chip and the reset pin of the Atmega.
This circuit resets the Atmega microcontroller each time a new serial connection is established, it is possible in this way to upload new sketches at any time. THe new connection resets the microcontroller and then the new firmware can be uploaded.
The drawback of this circuit is that it is not possible to support services that must survive new serial connections.
For example I am designing a Home Automation unit controlling some lights based on Arduino Nano. The lights can be turned on and off using some buttons, the state can be queried and changed using a serial connection.
I have designed the following circuit to Enable and Disable auto-reset using an output pin of the Arduino itself or from another controller.
This circuit has to be plugged to the ISP connector (which has the same pinout in all the Arduinos where it exists)
Using a Jumper it is possible to use the CLK or the MISO pin, or without any jumper the base of the transistor can be driven by any other source.
When a driving tension of 3.3 to 5V through the resistor puts the transistor in conduction the capacitor disables the auto reset.
In fact, in this situation the capacitor is fully charged and "eats" the negative spike coming from the #DTR of the ASB/UART adapter.
In my Arduino Nano CLK is D13 (the same pin connected to the led). When I put D13 up, I can open and close the virtual terminal on my laptop, even reset the computer or plug and unplug the USB (if the arduino is not power supplied by USB) and my Arduino does not reset its sketch.
If I turn off D13 I can upload a new sketch.