Not even that statement is clear. PortD, bit 0 (D0) is an INPUT (RX) to the serial port. PortD, bit 1 (D1) is an OUTPUT (TX) from the serial port.
My understanding is that D0, D1, etc are programmable as outputs and may be pulled up to 5V with internal pull ups. So when a 0 is written to the register the corresponding relay will activate. 1=off 0 = on…
What do you mean by “monitoring serial traffic (from the USB)”? Do you mean monitor the serial connection between a PC and the Arduino?
Are you collecting each input character and sending it to two different routines, one just to show to a curious viewer?
What do you do with each output character?
What does the title of your post mean: “shut off pins 0 and 1”? How do you maintain a serial connection if they are shut off?
The project is a position controller for making something like a spring.
When I did the layouts for this project, I made the assumption that serial thru the USB port was not the same as serial on pins D0 and D1.
(This is what I am trying to resolve)
Inputs D0-D3 for output relays, D4-D9 are operator interface buttons, a 10K variable pot is on A0, I2C communication on A4,A5 going to 2, 14 bit DAC’s. SPI on D10,11,12,13 for a encoder counter. 0 to 5v for a linear servo element and 0-5v for 4-20ma speed controller. (see image) That leaves, A1,A2,A3 for in process sensors like stop limits.
The system is normally in a stand by state, “monitoring” or waiting for process communication parameters.
There are about 10 required, but many others optional. Once the minimum required parameters are received the system may be actuated when the operator presses a “go” button.
As soon as the “request” to operate happens all USB serial is shut down.
The operating loop is basically in order, Read SPI (encoder) position, do some math, check parameters, set I2C DACs as required. Repeat till end parameter is reached.
When this cycle is completed, or interrupted, the processor goes back to monitoring USB.