Free up RX pin while still sending on TX?

It doesn't seem possible to free up the RX pin while using the serial port, using the Arduino API. Anyone know if it is possible to still use the RX pin as a DIO while still using the serial port on TX, by writing some fancy AVR code?


I figured it out. One register modification will switch off just the RX half of the serial module.


// Demonstration of how to simultaneously use the RX pin as DIO while using the TX pin for serial output.
// You should get recurring good news in the Serial Monitor.
// You should be able to measure the RX pin turning on and off in sync with the pin 13 LED.
// (For some reason the RX LED doesn't blink like I'd expected, but that's no big deal.)

#define RXPIN 0 // The arduino pin for RX
#define TXPIN 1 // The arduino pin for TX

void setup()
  // Set up the serial port.
  Serial.begin(9600);  // Turns on both TX and RX
  //  UCSR0B = (1<<RXEN0)|(1<<TXEN0);
  UCSR0B = (1<<TXEN0);  // Note: this one line might be enough to free up the RX pin.

  // enable interrupt on complete reception of a byte
  //sbi(UCSR0B, RXCIE0);

  pinMode(RXPIN, OUTPUT);


void loop()
  Serial.println("Still able to send stuff over TX!");
  // See if we can blink the RX pin while still sending stuff on the TX pin.
  int ledPin = 13;
  digitalWrite(ledPin, HIGH);   // sets the LED on.
  digitalWrite(RXPIN, HIGH);
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);
  digitalWrite(RXPIN, LOW);  // sets the LED off
  delay(1000);                  // waits for a second