SMARS project guidance

I recently built a SMARS (robotic vehicle) run by Arduino Uno R3 and MH Motor Shield, which I believe is similar to the Addafruit V1.
The basic sketch proved okay and and drove fwd, back, left & right this said all hardware good.
The next stage fit a Bluetooth board, HC06, for manual control, this set up okay and my Android tablet connects (Bluetooth LED static lit) but no control from the Android software controller. I double checked the HC06 using a breadboard and test sketch which proved I had I/O control of an LED. Looking online I have seen that using tx/rx 0&1 on the Arduino is not a good idea, this was from the build sheet I followed not wanting to use mismatched information, I uploaded the sketch without the motor board fitted.
Now my question, looking at the sketch where do I find the port settings to change from 0/1 to other ports and what ports do the motors use, I'm using a baud of 9600 which I confirmed works on my LED test.

#include <AFMotor.h>

AF_DCMotor MotorL(1);  //Motor for drive Left on M1
AF_DCMotor MotorR(2);  //Motor for drive Right on M2

const int buzPin = 2;  //set digital pin 2 as buzzer pin (use active buzzer)

String readString, action, Lspeed, Rspeed, actionDelay, stopDelay;  //declaring multiple strings

void setup(){
Serial.begin(9600);  //set up Serial library at 115200 bps
Serial.println("*SMARS Remote Control Mod*");

pinMode(buzPin, OUTPUT);  //sets the buzzer pin as an Output

// Set the speed to start, from 0 (off) to 255 (max speed)
// sometimes the motors don't have the same speed, so use these values to make the SMARS move straight
MotorL.setSpeed(255);
MotorR.setSpeed(255);
// turn off motors
MotorL.run(RELEASE);
MotorR.run(RELEASE);
}

void loop() {
while (Serial.available() > 0) {
  char c = Serial.read();  //gets one byte from serial buffer
  readString += c;

  if (c == '/n') {
    Serial.println("---------------");
    Serial.print(readString);  //prints string to serial port out

    int n1;
    int n2;

    // separate the string that receive from serial buffer into several substring
    action = readString.substring(0, 1);
    Lspeed = readString.substring(1, 4);
    Rspeed = readString.substring(4, 7);

    Serial.println(action);
    Serial.println(Lspeed);
    Serial.println(Rspeed);
    
    char carray1[7];  //declaring character array
    Lspeed.toCharArray(carray1, sizeof(carray1));  //passing the value of the string to the character array
    n1 = atoi(carray1);  //convert the char/string to a integer value

    char carray2[7];
    Rspeed.toCharArray(carray2, sizeof(carray2));
    n2 = atoi(carray2);

    Serial.println(n1);  //prints integer value n1 to serial port out
    Serial.println(n2);  //prints integer value n2 to serial port out

    readString = "";

    //move forward
    if(action.equals("F")){
      MotorL.setSpeed(n1);
      MotorR.setSpeed(n2);
      MotorL.run(FORWARD);
      MotorR.run(FORWARD);

      //move backward
    } else if(action.equals("B")){
      MotorL.setSpeed(n1);
      MotorR.setSpeed(n2);
      MotorL.run(BACKWARD);
      MotorR.run(BACKWARD);

      //turn left
    } else if(action.equals("L")){
    MotorL.setSpeed(n1);
    MotorR.setSpeed(n2);
    MotorL.run(BACKWARD);
    MotorR.run(BACKWARD);
    
    
    //turn right
    } else if(action.equals("R")){
      MotorL.setSpeed(n1);
      MotorR.setSpeed(n2);
      MotorL.run(BACKWARD);
      MotorR.run(BACKWARD);

      //stop
    } else if(action.equals("S")){
      MotorL.run(RELEASE);
      MotorR.run(RELEASE);

      //turn on horn
    }else if(action.equals("H")){
      digitalWrite(2, HIGH);
      delay(150);
      digitalWrite(2, LOW);
      delay(100);
      digitalWrite(2, HIGH);
      delay(250);
      digitalWrite(2, LOW);
    }
    }
    }
    }
    

If the bluetooth module uses Pin 0 and Pin 1, disconnect (remove) the bluetooth module before you upload the sketch.

Did you follow the instructions of this line?

Thank you for the reply.
Yes probably should have been more clear in my post, the BT module is connected to the motor board and both were removed before I uploaded the sketch to the standalone Arduino.
The BT module was preset to Baud 9600, this was confirmed in my separate breadboard test.

It looks like you are using Adafruit code.

Try the SMARS project code...

I had seen that but it appeared to require a different motor shield to the one I have so I was reluctant to use it.

Do both shields use the same Arduino pins?

I would expect so but I don't have one to compare, but as I said I do not want to mix hardware/software as that could only confuse matters.
When I chose the Motor Board it said it was a copy of the Adafruit V1type. If I could see in the uploaded sketch what ports are used I could then adapt.
Kevin McAleer runs a 'Fan Site' and is not the original creator who I have followed for my build.

Try connecting the devices without the shield by reading the sketch for pin usage.

I picked out a kit for use in helping others with this kit (and similar) and found the documentation lacking, so I used the small bit of their information given and added it to their drawing. The forum page has a few hundred hits from people looking for this kind of documentation. Make one for yourself.

Not seen a board like that before, the problem is I have no idea about what the software controller is sending to the BT module, that is why I am trying to stick to the original design as much as possible.

That board in post #8 is just another shield by another company.

The information sent and received between Arduino through the BT will be available on the Serial Monitor if the Arduino is using hardware serial (Arduino pins 0 and 1).

Serial.print(); is sending to the BT and Serial.read(); is arriving from the BT.

Thank you for your help, I appear to be going round in circles so will call it a day and find something more constructive to spend my time on.

Describe this.

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