Arduino Mega Serial 1,2,3 not working

Hi
I am new to programming with the Arduino. I am currently building a robot which is controlled via bluetooth. I am using the Arduino Mega (Chinese Clone). I have connected the HC-05 bluetooth module up using the serial port (tx, rx) but when I change it to serial1(tx1, rx1) it does not communicate at all! I have also tried using ports serial2 and serial3 but I get the same result.
Here is my code:

#include <AFMotor.h>
AF_DCMotor Motor1(1);
AF_DCMotor Motor2(2);
void setup()
{
  pinMode( 15, INPUT_PULLUP ); 
  Motor1.setSpeed(255);
  Motor2.setSpeed(255);
  Serial1.begin(9600);
  
  
  
}

void loop()
{        
if (Serial1.available()) {
    int c = Serial1.read();
    Serial1.print(c);
    
    if (c == '1') {
        Motor1.run(FORWARD);
        Motor2.run(FORWARD);     
        }
        else if (c == '2') {
          Motor1.run(BACKWARD);
          Motor2.run(BACKWARD);
        }
        
        else if (c == '3') {
          Motor1.run(BACKWARD);
          Motor2.run(FORWARD);
        }
        else if (c == '4') {
          Motor1.run(FORWARD);
          Motor2.run(BACKWARD);
        }
        else if (c == '5') {
          Motor1.run(RELEASE);
          Motor2.run(RELEASE);
        }

        
  }
}

I have seen other people with the same problem but the advice is to add this line of code in the setup for internal pull-up resistors how ever it does not change anything.

pinMode( 15, INPUT_PULLUP );

The only other idea was to change to TX and RX leads round because some of the clone Arduino's have the TX and RX ports labelled wrong.
If you ave any ideas for why this does not work please let me know as I am completely stuck!
Thanks
James

What device is connected to Serial1 that is sending characters to it?

edit: My bad. It is HC-05. Does it work on Serial? It should do fine on any other Serialx port. Do you have an o-scope or some type of digital signal analyzer?

How are you watching for input from the HC-05? You aren't watching for the data on the serial monitor, are you? Have you tried that? I made a few changes to your code.

#include <AFMotor.h>
AF_DCMotor Motor1(1);
AF_DCMotor Motor2(2);
void setup()
{
  pinMode( 15, INPUT_PULLUP );
  Motor1.setSpeed(255);
  Motor2.setSpeed(255);

  Serial.begin(9600)
  Serial1.begin(9600);
}

void loop()
{       
if (Serial1.available()) {
    int c = Serial1.read();

// change this to Serial
    Serial.print(c);
   
    if (c == '1') {
        Motor1.run(FORWARD);
        Motor2.run(FORWARD);     
        }
        else if (c == '2') {
          Motor1.run(BACKWARD);
          Motor2.run(BACKWARD);
        }
       
        else if (c == '3') {
          Motor1.run(BACKWARD);
          Motor2.run(FORWARD);
        }
        else if (c == '4') {
          Motor1.run(FORWARD);
          Motor2.run(BACKWARD);
        }
        else if (c == '5') {
          Motor1.run(RELEASE);
          Motor2.run(RELEASE);
        }

       
  }
}

Thank you so much!!!!
I can't believe I made such a stupid mistake.
I did not realise that the serial monitor would not show serial1. Thanks again
James
:smiley: :smiley: :smiley: :smiley: :smiley: