How to select TX/RX to be used

Its our first project related to arduino. Our project is using bluetooth and GSM. I need 2 TX/RX port one for bluetooth and one for GSM so the arduino we ordered has a two TX/RX. The problem is how do i select whether TX0/RX0 to be used for bluetooth and TX1/RX1 for the GSM? This is the program for the Bluetooth i found and it is the program i will use in the bluetooth part but it is for the arduino with 1 TX/RX port only:

const int ledPin = 2; // the pin that the LED is attached to
byte serialA;
void setup()
// initialize the serial communication:
Serial.begin(19200); //baud rate - make sure it matches that of the module you got:
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);

void loop() {

if (Serial.available() > 0) {serialA =;Serial.println(serialA);}

switch (serialA) {
case 1:
digitalWrite(ledPin, HIGH);
case 2:
digitalWrite(ledPin, LOW);
case 3:digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);



What to add or revise in that code so it will be assigned to TX0/RX0? Many thanks :slight_smile:

Just for completeness, which Arduino are you using?

If you have two serial ports, simply interacting with Serial object such as will use RX0/TX0. There is no need to select if one device is connected to one serial port. Which board are you using?

Use Serial for the normal port and Serial1 for the alternate port if you are using a Mega, Leonardo or Micro. Otherwise you will have to use a software serial emulator.

ATmega644 is what we are using. Thanks for the help guys :slight_smile:

If you have a Leonardo board, you only have one hardware serial port, instead of two.

Ok, Serial and Serial1 for 644. Which variant are you using, standard or bobuino? Maybe you are using sanguine?

the standard one

Jack Christensen has just made some pin mapping changes the past week. Make sure you get it and do some homework on it.

Alright sir thanks :slight_smile: