Pin 10 and 2 on Softwareserial Library

Im using an L293D driver shield over an Arduino UNO and trying to use pin 10 and 2 via softwareserial to communicate via hm10 module.

Im pretty sure pin 2 is free on the shield because it brings its own solder pad, but what about pin 10? I thought it was used by a stepper, but Im not using steppers, Im only using 4 dc motors.

By now, you REALLY ought to know to post links to the hardware you are asking questions about, unless you really want us to answer "Well, maybe".

If your motor control shield is like this one:

Pin 10 is used for one of the two servo outputs.
Pin 2 appears to be free.

Sorry its a chinese copy Of the L293d Arduino. I doubt really have a link to its manufacturer.

As for pin 10 i understand its used by the servo but im not using the servos at all. So It should be free, shouldn’t it.

I’ll try to get a link to the hardware from the seller.

You could measure it with a multimeter - if it has infinite resistance to both ground and 5V (use the diode
setting in both polarities), its unconnected. (Shield disconnected and unpowered, obviously).

Ok here is the deal, here is my setup and here is my code:

The issue is that the motors make a small humming sound whenever I enter a command like 1 or 2 or whatever and they stop making it when I enter 5 for BRAKE.

I measured the V from the 4xAA and it gives 5.78V at the L293D incoming power terminal. But when I measured the power at the motor terminals I get only 0.38V-0.57V.

Here’s the thing. I started this with a hardcoded forward and backward, then I moved up to IR and realized I needed a pin to get data from the IR Transmitter so I soldered a jumper to pin 10 and got away with it. But I think I remember that IRRemote’s timer conflicted with some other pins and thus I couldn’t use 1 or 2 of the dc motors. To get it to work I did a no-no which worked just for illustration purposes, I wired M3 to M2 and M1 to M4, which meant that I could call forward() on M4 and M1 would also move automatically and I could do the same for M2 and M2 would move automatically.

Now that I tried my bt code, I got that humming sound, but I removed the wiring between the motors and now the thing works. I remember the problem with IR was that IRRemote uses timer2 which is also used by pins 3 and 11. That is why I had to use pin 10 and soldered the jumper to it. But it also rendered motors 1&2 unavailable so I had to dirty-wire them to 3&4.

What Im still curious about is why were the motors getting so little power when on bt, but not when on IR? On IR the car moved around everywhere just fine.

#include <SoftwareSerial.h>// import the serial library
#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor3(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor4(4, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

SoftwareSerial btserial(10, 2); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
char c=' ';
boolean NL = true;

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  btserial.begin(9600);
    
  motor1.setSpeed(200);     // set the speed to 200/255
  motor2.setSpeed(200);     // set the speed to 200/255
  motor3.setSpeed(200);     // set the speed to 200/255
  motor4.setSpeed(200);     // set the speed to 200/255

  btserial.write("AT\r\n");
  btserial.write("AT+NAME\r\n");
}

void loop() {
  // Leer bluetooth, si es 1, Adelante...
  if (btserial.available()){
    c=btserial.read();
    Serial.write(c);

    if(c=='1'){   // if number 1 pressed ....
        Serial.write("Forward");
      forward();
    }
    if(c=='2'){// if number 0 pressed ....
        Serial.write("Backward");

      backward();
    }
    if(c=='3'){// if number 0 pressed ....
        Serial.write("Left");

      left();
    }
    if(c=='4'){// if number 0 pressed ....
        Serial.write("Right");
      right();
    }
    if(c=='5'){// if number 0 pressed ....
        Serial.write("BRAKE");
      brake();
    }
}

  // Serial Monitor Write BT
    if (Serial.available()){
        c = Serial.read();
      
        // do not send line end characters to the HM-10
        if (c!=10 & c!=13 ) {  
             btserial.write(c);
        }
 
        // If there is a new line print the ">" character.
        if (NL) { Serial.print("\r\n>");  NL = false; }
        Serial.write(c);
        if (c==10) { NL = true; }
    }  

}

void forward(){
  Serial.println("running forward");
  motor1.run(FORWARD);   
  motor2.run(FORWARD);     

}
void backward(){
  Serial.println("running backward");
  motor3.run(BACKWARD);    
  motor4.run(BACKWARD);    
}

void left(){
  motor3.run(FORWARD);   
}
void right(){
  motor4.run(FORWARD);    
}

void brake(){
  motor1.run(RELEASE);    
  motor2.run(RELEASE);    
  motor3.run(RELEASE);    
  motor4.run(RELEASE);      
}

What Im still curious about is why were the motors getting so little power when on bt, but not when on IR?

The motors are NOT "on bt" OR "on IR", so, your question makes no sense.

i know the motors aren't. But I mean when I use IR vs BT.

When I use IR, I use the IRRemote library and therefore cannot use pin 10 which means I cant use m1 and m2, so I must piggy-back them onto m3 and m4.

When I use BT I dont use IRRemote library and therefore I can use all 4 motors right out of their block terminals.

The question I have is, why if I leave m1 and m2 piggy backed onto m3 and m4, and I stop using the IRRemote library, when I try to run the motors, they only get 0.5V and therefore only make a humming sound without being able to move the tires?

The question I have is, why if I leave m1 and m2 piggy backed onto m3 and m4, and I stop using the IRRemote library, when I try to run the motors, they only get 0.5V and therefore only make a humming sound without being able to move the tires?

Post the IR code. Post the BT code. There must be something that the IR code does that the BT code does not do.

This is the bluetooth code:

#include <SoftwareSerial.h>// import the serial library
#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor3(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor4(4, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

SoftwareSerial btserial(10, 2); // RX, TX
char c=' ';
boolean NL = true;

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  btserial.begin(9600);
  btserial.println("Bluetooth On please press 1 or 0 blink LED ..");
    
  motor1.setSpeed(200);     // set the speed to 200/255
  motor2.setSpeed(200);     // set the speed to 200/255
  motor3.setSpeed(200);     // set the speed to 200/255
  motor4.setSpeed(200);     // set the speed to 200/255

  btserial.write("AT\r\n");
  btserial.write("AT+NAME\r\n");
}

void loop() {
  // Leer bluetooth, si es 1, Adelante...
  if (btserial.available()){
    c=btserial.read();
    Serial.write(c);

    if(c=='1'){   // if number 1 pressed ....
        Serial.write("Forward");
      forward();
    }
    if(c=='2'){// if number 0 pressed ....
        Serial.write("Backward");

      backward();
    }
    if(c=='3'){// if number 0 pressed ....
        Serial.write("Left");

      left();
    }
    if(c=='4'){// if number 0 pressed ....
        Serial.write("Right");
      right();
    }
    if(c=='5'){// if number 0 pressed ....
        Serial.write("BRAKE");
      brake();
    }
}

  // Serial Monitor Write BT
    if (Serial.available()){
        c = Serial.read();
      
        // do not send line end characters to the HM-10
        if (c!=10 & c!=13 ) {  
             btserial.write(c);
        }
 
        // Echo the user input to the main window. 
        // If there is a new line print the ">" character.
        if (NL) { Serial.print("\r\n>");  NL = false; }
        Serial.write(c);
        if (c==10) { NL = true; }
    }  

}

void forward(){
  Serial.println("running forward");
  motor1.run(FORWARD);   
  motor2.run(FORWARD);
  motor3.run(FORWARD);   
  motor4.run(FORWARD);
  delay(3000);  
  brake();
}
void backward(){
  Serial.println("running backward");
  motor1.run(BACKWARD);   
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);   
  motor4.run(BACKWARD);
  delay(3000);  
  brake();   
}

void left(){
  motor3.run(FORWARD);   
  motor2.run(BACKWARD);   
}
void right(){
  motor4.run(FORWARD);    
  motor1.run(FORWARD);     
}

void brake(){
  motor1.run(RELEASE);    
  motor2.run(RELEASE);    
  motor3.run(RELEASE);    
  motor4.run(RELEASE);      
}

and here is the IR code:

#include <AFMotor.h>
#include <IRremote.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor3(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor4(4, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  irrecv.enableIRIn(); // Start the receiver

  motor1.setSpeed(200);     // set the speed to 200/255
  motor2.setSpeed(200);     // set the speed to 200/255
  motor3.setSpeed(200);     // set the speed to 200/255
  motor4.setSpeed(200);     // set the speed to 200/255
}

void loop() {

  //Recibir & Analizar codigo recibido
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);

      if (results.value == 0x2C2E80FF){//0xFD807F){
        Serial.println("forward");
        forward();
        delay(2000);
        brake();
      } else if (results.value == 0x5A1A483D){//0xFD906F){
        Serial.println("backward");
        backward();
        delay(2000);
        brake();
      } else if (results.value == 0x9578646A){//0xFD20DF){
        Serial.println("left");
        left();
        delay(1000);
        brake();  
      } else if (1==1) {
        Serial.println("right");//DC18602C
        right();
        delay(1000);
        brake();  
      }

      irrecv.resume(); // Receive the next value
  } 
}

void forward(){
  Serial.println("running forward");
  motor3.run(FORWARD);   
  motor4.run(FORWARD);     

}
void backward(){
  Serial.println("running backward");
  motor3.run(BACKWARD);    
  motor4.run(BACKWARD);    
}

void left(){
  motor3.run(FORWARD);   
}
void right(){
  motor4.run(FORWARD);    
}

void brake(){
  motor1.run(RELEASE);    
  motor2.run(RELEASE);    
  motor3.run(RELEASE);    
  motor4.run(RELEASE);      
}