Hi,
Bit of a strange question.
Suppose you have a sketch which you do a Serial1.begin(9600); in the setup().
Is there a way, to determine from this, what pin on the particular Arduino hardware you are using, this is, so it can be used to dictate something else?
Basically what I am trying to do involves the ability to recover from a failure of a connected device on serial. I have code which can recover, if it knows something has gone wrong, but at the moment when the power is pulled from the remote device, Serial1 RX pin is floating, its not pulled high or low.
Short of adding to the hardware, I thought we could take advantage of the internal pullup.
So, if there was a way to determine the pin from the UART that we are using Serial1, then add a line to enable that UART's RX pin, to be Internal Pullup. pinmode(Serial1_RX, INPUT_PULLUP);
for example.
Works find manually defining, it, pinmode(19, INTERNAL_PULLUP) after doing the Serial1.begin(9600); statement.
Serial1 on one Arduino, is likely a different pin to another Arduino.
Just curious if there might be any way to determine this from the sketch. Just trying to make this a little more universal.
Thanks