I want to use the hardware serial port (pin 0 RX and 1 TX) to connect a MAX485 IC. Internally these pins are also connected to the onboard USB to serial converter microcontroller which is used to flash the ATMega328 using the bootstrap code.
I know I can't have two different serial devices (USB and MAX485 in that case) at the same time without interfering each other. Given that I want to use the HardwareSerial and not a solution based on SoftwareSerial I have added two jumpers on my design that let me connect and disconnect the MAX485 to the RX pin 0 and TX pin 1 if I want to upload a new sketch.
I have two questions:
- Is there an elegant way to reduce the two jumpers TX and RX to just one that when shorted connects or desconects both pins at the same time (max RX and TX to pin 0 and 1 on the Arduino)
- Is it possible to use a transistor software controlled by an arduino pin to have the same efect and let me choose when I want the max485 connected and when I want to fallback to the arduino USB to ttl?
The idea is that if the device is reseted by the computer to upload a new sketch the USB device will be active, once the device has booted as part of the boot process will enable the MAX device and the built in USB will be disabled as the MAX IC will have preference.