Need programming example to use A0/A1 (analog pins) as Serial I/O (Tx/Rx)

Could someone give me a code piece how to initialize and use AO/A1 (analog pins) as Rx/Tx Serial I/O.

In which arduino board?

Ah, sorry, forgot. Arduino Nano

You can't select any pins for hardware Serial interface other than predefined 0 & 1. But you can create additional software-based serial port.
Read the documentation for SoftwareSerial library

#include <SoftwareSerial.h>

SoftwareSerial mySerial(A0, A1); // RX, TX

void setup()
{
  // set the data rate for the SoftwareSerial port
  mySerial.begin(38400);
  mySerial.println("Hello, world?");
}

void loop() {}

Thanks. That's what I wanted to know, mySerial(A0, A1); // RX, TX

so mark the thread as "solved"

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.