nrf24l01 + old aritronics + L298N need a little help.

Sorry for posting another question before replying to your previous. I didn't realize we had rolled onto a new page.

Here is a simple drawing of my pots. Connections are as simple as it gets Left post to - right to + middle to signal.

I suspect the limited range is because of the way the pots are mounted in the old radio. It limits travel somewhat so we are not getting full range.

I also added a picture of the back of the radio. There are some extra wires. I want to leave options open for future expansions, but don't want anything else connected while I'm still getting the first stage going.

PaulS:
If you print both the value read from the pot and the value you calculate, I'm sure you'll reach for your dunce hat.

Ya whatever. I'll just go sit in a corner for a bit here.

If your Pot is connected as in your diagram I would expect it to produce ADC values from 0 to 1023 - but maybe the joystick levers cannot move the Pot through its full range.

If the range is from 319 to 567 it would probably simplify the maths if you subtract 319 so that the range is from 0 to 248.

And if you subtract a further 124 (making 443) you will get a symmetrical range from -124 to + 124.

And 124 * 2 is near enough to 255 to make little difference.

...R

Ok, I'm going nuts here. With the code as it is written bellow. I can use the right joystick to control right motor forward works ok. Reverse starts fast then slows down. That's an easy fix. left motor still does nothing.

Serial output is exactly as expected.

/*
  ---- Receiver Code ----
  Mert Arduino Tutorial & Projects (YouTube)
  Please Subscribe for Support
*/

#include <Servo.h>    //the library which helps us to control the servo motor
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem (nRF24L)

//define our L298N control pins
//Motor Left
const int enA = 10;     //enA  for speed control
const int IN1 = 2;    // IN1
const int IN2 = 3;   // IN2
//Motor RIght
const int enB = 5;       //enB for speed control
const int IN3 = 4;     // IN3
const int IN4 = 6;    // IN4
int LeftMSpeed;   // interger to capture speed
int RightMSpeed; // to capture R speed
int LMotor;
int RMotor;
int joystick[8]; //The element array holding the data from joysticks
int fail = 0; // for when we lose radio range
int servo_pos;
bool newData = false;  //
int leftAdcVal;
int leftMotorVal;
int rightAdcVal;
int rightMotorVal;
//define the servo name
Servo myServo;


RF24 radio(7, 8);     /*This object represents a modem connected to the Arduino.
                      Arguments 5 and 10 are a digital pin numbers to which signals
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.



void setup() {
  Serial.begin(115200); // for outputting debuggin information to serial monitor
  delay(3000);
  Serial.println("Nrf24l01 Receiver Starting");
  pinMode(enB, OUTPUT); // RIgnt Motor speed PWM
  pinMode(enA, OUTPUT); //Left Motor Speed PWM
  pinMode(IN3, OUTPUT); //Right Forward
  pinMode(IN1, OUTPUT); //Left Forward
  pinMode(IN2, OUTPUT); //Left Backward
  pinMode(IN4, OUTPUT);//Right Backward

  //define the servo input pins
  myServo.attach(14); //A0

  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();           //enable receiving data via modem
}

void loop() {

  if (radio.available() ) {
    radio.read( joystick, sizeof(joystick) ); // Fetch the data payload
    leftAdcVal = joystick[0];           // range 0 to 1023
    leftMotorVal = leftAdcVal - 443;    // range -124 to +124
    rightAdcVal = joystick[2];           // range 0 to 1023
    rightMotorVal = rightAdcVal - 443;    // range -124 to +124
    analogWrite(enA, leftMotorVal);
    analogWrite(enB, rightMotorVal);
    Serial.print("LMotor =");
    Serial.print(leftMotorVal);
    Serial.print("      RMotor =");
    Serial.println(rightMotorVal);
  }

  LMotor = joystick[0];           // range 319 to 567
  // leftMotorVal = leftAdcVal - 443;    // range -64 to +64
  // subtracting 513 (rather than 512) ensures that no later value will exceed 255
  if (LMotor < 504) {//This is backwards
   // LeftMSpeed = map(LMotor, 504, 414, 0, 255); //366
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
    //  analogWrite(enA, LeftMSpeed);

  }

  else if (LMotor > 504 && RMotor < 511) {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
  }

  else if (LMotor > 511) {//This is forwards
   // LeftMSpeed = map(LMotor, 511, 604, 0, 255);
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    //  analogWrite(enA, LeftMSpeed);


  }



  RMotor = joystick[2];
  if (RMotor < 505)  { //this is backwards
  //  RightMSpeed = map(RMotor, 505, 366, 0, 255);
    //Set Right motor backwards
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
    //  analogWrite(enB, RightMSpeed);

  }
  else if (RMotor > 506 && RMotor < 512) {
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, LOW);
  }

  else if (RMotor > 512) { //this is forwards
 //   RightMSpeed = map(RMotor, 512, 660, 0, 255);
    //Set Left motor forwards
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);
    //   analogWrite(enB, RightMSpeed);



  }





  // for the servo motor
  servo_pos = map(joystick[7], 0, 1024, 0, 255);
  myServo.write(servo_pos);
}

left motor still does nothing.

You have an awful lot of code for (still) having a fundamental problem.

Get rid of most of the code. Just make one motor spin in one direction for 5 seconds. Then spin the other motor the same way, for the same length of time. Then, make each motor spin the other way, for the same length of time. Lock the joysticks and radios away until you can positively control the motors.

it appears that shifting the numbers down so that we have -124 -- + 124 doesn't translate directly as I, and I assume you expected.

I was expecting the enA pin to disregard the - and take just the numbers to feed to the speed controllers. So we are back to mapping for both a forward and a reverse value.

PaulS:
You have an awful lot of code for (still) having a fundamental problem.

Get rid of most of the code. Just make one motor spin in one direction for 5 seconds. Then spin the other motor the same way, for the same length of time. Then, make each motor spin the other way, for the same length of time. Lock the joysticks and radios away until you can positively control the motors.

Paul, That's where I started if you read up on this thread. I broke away from the wireless system and used simple joysticks and a wired connection between the joysticks ==> arduino ==> motor controller ==> motors. Everything worked perfectly. I even added in a servo and a pot and controlled the motion of the servo using the pot. Wired everything worked perfectly.

jonawadl:
Everything worked perfectly. I even added in a servo and a pot and controlled the motion of the servo using the pot. Wired everything worked perfectly.

Then the obvious question is how does the motor control code in the non-working program differ from the working program?

Can you remove the "broken" motor control code and replace it with the working code?

...R

I tried to do that. I have uploaded my wired code set here, but I will upload both again together. I have been comparing the two and con't find the difference that would make it go.

/*
  ---- Receiver Code ----
  Mert Arduino Tutorial & Projects (YouTube)
  Please Subscribe for Support
*/

#include <Servo.h>    //the library which helps us to control the servo motor
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem (nRF24L)

//define our L298N control pins
//Motor Left
const int enA = 10;     //enA  for speed control
const int IN1 = 2;    // IN1
const int IN2 = 3;   // IN2
//Motor RIght
const int enB = 5;       //enB for speed control
const int IN3 = 4;     // IN3
const int IN4 = 6;    // IN4
int LeftMSpeed;   // interger to capture speed
int RightMSpeed; // to capture R speed
int LMotor;
int RMotor;
int joystick[8]; //The element array holding the data from joysticks
int fail = 0; // for when we lose radio range
int servo_pos;
bool newData = false;  //
int leftAdcVal;
int leftMotorVal;
int rightAdcVal;
int rightMotorVal;
//define the servo name
Servo myServo;


RF24 radio(7, 8);     /*This object represents a modem connected to the Arduino.
                      Arguments 5 and 10 are a digital pin numbers to which signals
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.



void setup() {
  Serial.begin(115200); // for outputting debuggin information to serial monitor
  delay(3000);
  Serial.println("Nrf24l01 Receiver Starting");
  pinMode(enB, OUTPUT); // RIgnt Motor speed PWM
  pinMode(enA, OUTPUT); //Left Motor Speed PWM
  pinMode(IN3, OUTPUT); //Right Forward
  pinMode(IN1, OUTPUT); //Left Forward
  pinMode(IN2, OUTPUT); //Left Backward
  pinMode(IN4, OUTPUT);//Right Backward

  //define the servo input pins
  myServo.attach(14); //A0

  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();           //enable receiving data via modem
}

void loop() {

  if (radio.available() ) {
    radio.read( joystick, sizeof(joystick) ); // Fetch the data payload
    leftAdcVal = joystick[0];           // range 0 to 1023
    leftMotorVal = leftAdcVal - 443;    // range -124 to +124
    rightAdcVal = joystick[2];           // range 0 to 1023
    rightMotorVal = rightAdcVal - 443;    // range -124 to +124
    analogWrite(enA, leftMotorVal);
    analogWrite(enB, rightMotorVal);
    Serial.print("LMotor =");
    Serial.print(leftMotorVal);
    Serial.print("      RMotor =");
    Serial.println(rightMotorVal);
  }

  LMotor = joystick[0];           // range 319 to 567
  // leftMotorVal = leftAdcVal - 443;    // range -64 to +64
  // subtracting 513 (rather than 512) ensures that no later value will exceed 255
  if (LMotor < 504) {//This is backwards
   // LeftMSpeed = map(LMotor, 504, 414, 0, 255); //366
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
    //  analogWrite(enA, LeftMSpeed);

  }

  else if (LMotor > 504 && RMotor < 511) {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
  }

  else if (LMotor > 511) {//This is forwards
   // LeftMSpeed = map(LMotor, 511, 604, 0, 255);
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    //  analogWrite(enA, LeftMSpeed);


  }



  RMotor = joystick[2];
  if (RMotor < 505)  { //this is backwards
  //  RightMSpeed = map(RMotor, 505, 366, 0, 255);
    //Set Right motor backwards
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
    //  analogWrite(enB, RightMSpeed);

  }
  else if (RMotor > 506 && RMotor < 512) {
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, LOW);
  }

  else if (RMotor > 512) { //this is forwards
 //   RightMSpeed = map(RMotor, 512, 660, 0, 255);
    //Set Left motor forwards
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);
    //   analogWrite(enB, RightMSpeed);



  }





  // for the servo motor
  servo_pos = map(joystick[7], 0, 1024, 0, 255);
  myServo.write(servo_pos);
}

Wired code that worked:

   #include <Servo.h>; // added by jonawadl
    //Joystick Pins
    int x_key = A0;                                               
    int y_key = A1;                                               
    int x_pos;
    int y_pos;
    //Motor Pins
    int EN_A = 11;      //Enable pin for first motor
    int IN1 = 9;       //control pin for first motor
    int IN2 = 8;       //control pin for first motor
    int IN3 = 7;        //control pin for second motor
    int IN4 = 6;        //control pin for second motor
    int EN_B = 10;      //Enable pin for second motor
    //Servo pins added by jonawadl
    int pot_pin = A2;
    //Define Servo Name
    Servo myServo; // added by jonawadl
    int pot_value;
    
    int servo_pos;
    //Initializing variables to store data
    int motor_speed;
    int motor_speed1;
    void setup ( ) {
      Serial.begin (9600); //Starting the serial communication at 9600 baud rate
      //Initializing the motor pins as output
      pinMode(EN_A, OUTPUT);
      pinMode(IN1, OUTPUT);  
      pinMode(IN2, OUTPUT);
      pinMode(IN3, OUTPUT);  
      pinMode(IN4, OUTPUT);
      pinMode(EN_B, OUTPUT);
      //Initializng the joystick pins as input
      pinMode (x_key, INPUT) ;                     
      pinMode (y_key, INPUT) ; 
      myServo.attach(17); // added by jonawadl                    
    }
    void loop () {
        x_pos = analogRead (x_key) ;  //Reading the horizontal movement value
        y_pos = analogRead (y_key) ;  //Reading the vertical movement value
        pot_value = analogRead (pot_pin);
       
    if (x_pos < 400){     //Rotating the left motor in clockwise direction
        motor_speed = map(x_pos, 400, 0, 0, 255);   //Mapping the values to 0-255 to move the motor
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, HIGH);
        analogWrite(EN_A, motor_speed);
      }
    else if (x_pos>400 && x_pos <600){  //Motors will not move when the joystick will be at center
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, LOW);
      }
      
    else if (x_pos > 600){    //Rotating the left motor in anticlockwise direction
        motor_speed = map(x_pos, 600, 1023, 0, 255);
        digitalWrite(IN1, HIGH);
        digitalWrite(IN2, LOW);
        analogWrite(EN_A, motor_speed);
      }
       
    if (y_pos < 400){         //Rotating the right motor in clockwise direction
        motor_speed1 = map(y_pos, 400, 0, 0, 255);
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, HIGH);
        analogWrite(EN_B, motor_speed1);
      }
    else if (y_pos>400 && y_pos <600){
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, LOW);
      }
      
    else if (y_pos > 600){        //Rotating the right motor in anticlockwise direction
        motor_speed1 = map(y_pos, 600, 1023, 0, 255);
        digitalWrite(IN3, HIGH);
        digitalWrite(IN4, LOW);
        analogWrite(EN_B, motor_speed1);
      }
      servo_pos = map(pot_value, 0, 1024, 0,255);  // added by jonawadl
      myServo.write(servo_pos);   // added by jonawadl
      }

In the receiver code you posted in Reply #26 both of the motors have analogWrite() commented out.

Also the map() statements are different from the working code.

What happens if you substitute the working code for the non-working code AND make the other variables in your wireless program match the working code.

...R

I have had a go at reorganising the working code in Reply #26 into a series of short functions to separate the activities. If you do that it makes the code much more portable. To use the revised code in your wireless program you would just need to change the function getInputs()

(I have not tested this so there may be some silly typos)

void loop() {
    getInputs();
    calculateMotorValues();
    calculateServoPosition();
    driveMotors();
    updateServo();
}


//============

void getInputs() {
    x_pos = analogRead (x_key) ;  //Reading the horizontal movement value
    y_pos = analogRead (y_key) ;  //Reading the vertical movement value
    pot_value = analogRead (pot_pin);
}

//===========

void calculateMotorValues() {
    motorSpeed = 0;
    if (x_pos < 400){     //Rotating the left motor in clockwise direction
        motor_speed = map(x_pos, 400, 0, 0, 255);
        motorDir = 'F';
    }
    else if (x_pos > 600){    //Rotating the left motor in anticlockwise direction
        motor_speed = map(x_pos, 600, 1023, 0, 255);
        motorDir = 'R';
    }
    
    motorSpeed1 = 0;
    if (y_pos < 400){     //Rotating the left motor in clockwise direction
        motor_speedy = map(y_pos, 400, 0, 0, 255);
        motorDir1 = 'F';
    }
    else if (y_pos > 600){    //Rotating the left motor in anticlockwise direction
        motor_speed1 = map(y_pos, 600, 1023, 0, 255);
        motorDir1 = 'R';
    }
}

//=============

void calculateServoPosition() {
    servo_pos = map(pot_value, 0, 1024, 0,255); 
}

//=============

void driveMotors() {
    if (motorDir == 'F') {
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, HIGH);
    }
    else {
        digitalWrite(IN1, HIGH;
        digitalWrite(IN2, LOW);
    }
    analogWrite(EN_A, motor_speed);
    
    if (motorDir1 == 'F') {
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, HIGH);
    }
    else {
        digitalWrite(IN3, HIGH);
        digitalWrite(IN4, LOW);
    }
    analogWrite(EN_B, motor_speed);
    
}

//==============

void updateServo() {
    myServo.write(servo_pos); 
}

...R

PS ... If you are going to use this version be sure to get it working in the wired version first.

Ok, before I go to look at your code very closely, I have made some changes of my own that I want you to look at.

I saved a new version of the existing code I had and completely took out the motor control and replaced it with the motor control from the working wired sketch. Then I added some serial.print code to see what it does.

With a bit of tweaking, I was able to get the serial output to do exactly what I expected it to do. I was reading the input from joystick[2] and the output to LeftMSpeed for both motors. They are exactly the same. I push joystick up I seed joystick input rise to expected values. At the same time, LeftMSpeed goes from 0 - 255 in a smooth sweep exactly as I would expect from a working code.

Here's the weird part though. While the right motor does everything right, the left motor does not twitch UNTIL LeftMSpeed hits 255 in either forward or reverse direction. Then it kicks in and goes at full speed in whatever direction is required of it. I've swapped the motors left to right, I've changed out the speed controller with brand new.

Can anybody suggest what else might be the problem?

In the code you will notice that some of the serial.print stuff is commented out. That's because I'm no good at formatting the output yet so I had to output one motor at a time to get a clear reading.

/*
  ---- Receiver Code ----
  Mert Arduino Tutorial & Projects (YouTube)
  Please Subscribe for Support
*/

#include <Servo.h>    //the library which helps us to control the servo motor
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem (nRF24L)

//define our L298N control pins
//Motor Left
const int enA = 10;     //enA  for speed control
const int IN1 = 2;    // IN1
const int IN2 = 3;   // IN2
//Motor RIght
const int enB = 5;       //enB for speed control
const int IN3 = 4;     // IN3
const int IN4 = 6;    // IN4
int LeftMSpeed;   // interger to capture speed
int RightMSpeed; // to capture R speed
int LMotor;
int RMotor;
int joystick[8]; //The element array holding the data from joysticks
int fail = 0; // for when we lose radio range
int servo_pos;
bool newData = false;  //
int leftAdcVal;
int leftMotorVal;
int rightAdcVal;
int rightMotorVal;
//define the servo name
Servo myServo;


RF24 radio(7, 8);     /*This object represents a modem connected to the Arduino.
                      Arguments 5 and 10 are a digital pin numbers to which signals
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.



void setup() {
  Serial.begin(115200); // for outputting debuggin information to serial monitor
  delay(3000);
  Serial.println("Nrf24l01 Receiver Starting");
  pinMode(enB, OUTPUT); // RIgnt Motor speed PWM
  pinMode(enA, OUTPUT); //Left Motor Speed PWM
  pinMode(IN3, OUTPUT); //Right Forward
  pinMode(IN1, OUTPUT); //Left Forward
  pinMode(IN2, OUTPUT); //Left Backward
  pinMode(IN4, OUTPUT);//Right Backward

  //define the servo input pins
  myServo.attach(14); //A0

  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();           //enable receiving data via modem
}

void loop() {

  if (radio.available() ) {
    radio.read( joystick, sizeof(joystick) ); // Fetch the data payload

    leftAdcVal = joystick[0];  //Reading the horizontal movement value xpos
    rightAdcVal = joystick[2];  //Reading the vertical movement value ypos
    //Serial.print("LMotor =");
    //Serial.print(joystick[0]);
    Serial.print("      RMotor =");
    Serial.print(joystick[2]);

    if (leftAdcVal < 504) {    //Rotating the left motor in clockwise direction
      LeftMSpeed = map(leftAdcVal, 504, 416, 0, 255);   //Mapping the values to 0-255 to move the motor
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      analogWrite(enA, LeftMSpeed);
    //  Serial.print("    LeftMSpeedR =");
    //  Serial.println(LeftMSpeed);
    }
    else if (leftAdcVal > 504 && leftAdcVal < 517) { //Motors will not move when the joystick will be at center
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, LOW);
    //  Serial.print("    LSTOP =");
    //  Serial.println(LeftMSpeed);
    }

    else if (leftAdcVal > 517) {   //Rotating the left motor in anticlockwise direction
      LeftMSpeed = map(leftAdcVal, 517, 605, 0, 255);
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      analogWrite(enA, LeftMSpeed);
   //   Serial.print("    LeftMSpeedF =");
   //   Serial.println(LeftMSpeed);
    }

    if (rightAdcVal < 508) {        //Rotating the right motor in clockwise direction
      RightMSpeed = map(rightAdcVal, 508, 364, 0, 255);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      analogWrite(enB, RightMSpeed);
      Serial.print("    RightMSpeedR =");
      Serial.println(RightMSpeed);
    }
    else if (rightAdcVal > 509 && rightAdcVal < 512) {
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, LOW);
      Serial.print("    RSTOP =");
      Serial.println(LeftMSpeed);
    }

    else if (rightAdcVal > 511) {       //Rotating the right motor in anticlockwise direction
      RightMSpeed = map(rightAdcVal, 511, 652, 0, 255);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      analogWrite(enB, RightMSpeed);
      Serial.print("    LeftMSpeedF =");
      Serial.println(RightMSpeed);
    }
    // for the servo motor
    servo_pos = map(joystick[7], 0, 1024, 0, 255);
    myServo.write(servo_pos);
  }
}

This does not inspire confidence

    Serial.print("    LeftMSpeedF =");
      Serial.println(RightMSpeed);

When I saw this

the left motor does not twitch UNTIL LeftMSpeed hits 255 in either forward or reverse direction. Then it kicks in and goes at full speed in whatever direction is required of it.

my first thought was that you have the driver pins wired incorrectly.

Another wild thought ...
You are using pin 10 for the PWM signal for the left motor and pin 10 is the Slave Select pin for SPI communication. You don't have to use it for SPI and, as required, you do have it set as OUTPUT. I don't know if its role in connection with SPI would affect its ability to do PWM but it might be worth trying a different PWM pin to see what happens.

...R

quote/This does not inspire confidence
Code: [Select]

Serial.print(" LeftMSpeedF =");
Serial.println(RightMSpeed);
/quote

Ya, that's a bit of a goof, but does not matter to the end result because its on the right motor, which is working as it should.

I have experimented with the pins too. I switched to 9 for pwm for a bit to test. It made no difference but it did introduce some chatter to the servo for some reason so I switched it back.

Next step, I'm going to switch out the big 12V motors for something that might be easier to turn. It's a long shot because one seems to work fine and I have swapped left to right already.

jonawadl:
quote/This does not inspire confidence
Code: [Select]

Serial.print(" LeftMSpeedF =");
Serial.println(RightMSpeed);
/quote

Ya, that's a bit of a goof, but does not matter to the end result because its on the right motor, which is working as it should.

My concern is that you have been looking at data for working right motor thinking that it is the data for the left motor. Maybe if you get it to print LeftMSpeed you will see that the value is not working the way you think.

If the motors are working with the wired code then they should work with the wireless code. Don't go wasting your time and mental energy on pointless experiments.

If you reorganize the code as I suggested you can use the exact same code (apart from one function) for both wired and wireless. That way you greatly reduce the area for exploration if the wireless version does not work.

You have not said, but I have been assuming that you tested your wired code on the exact same hardware as the wireless code (apart from the wireless hardware, of course).

...R

Ok I went back to the proverbial drawing board. I tore everything down and went back to a wired system to check my understanding that everything was working to begin with.

I discovered that I had a basic on-off forward reverse switch with one stick and a perfect speed controller forward and reverse on the other stick.

This would make somebody believe there's a problem with the code. But that's not the case.

I have one of these units.

When I take the six input pins and directly mirror them so that the right stick controls the left motor, everything reverses itself. Now the sticks have reversed roles. They do the opposite of what they did before. To me that indicates a hardware problem.

Here's the sticker though. I have three L298N units. All three behave exactly the same. Should I believe they are all faulty?

After further review, I think there's something else going on. When I mirror all connections, the opposite joystick works as expected but the opposite motor works as expected too.

So both channels in the L298N work, it just depends on the input.

I can't think it through here. I thought I had it. I'll do some thinking to see if I can solve what's going on.

and one more update for tonight. I went off the rails a bit and hooked up two L298N one for left motor one for right motor. Same results. It's always PWM pin 10 that has proportional control.

Ok, I lied about not posting again. today. After the last experiment I realized it had to lie in the code. So I went and did more reading and looking for more examples of working code.

I came across this site DC Motors with L298N Dual H-Bridge and Arduino | DroneBot Workshop. That was a fun read. I got both motors working as they should with wired connections. I'll play with the wireless from here and post my results back.

Sorry for leading people on a goose chase with code that wasn't working in the first place. Im sure I tired it and realized I had forward and reverse on both sticks then checked only one for proportional and it happened to be the right one.

Sorry but none of what you are saying about changing connections and reversed behaviour is understandable without a clear wiring diagram (NOT Fritzing, please) and the program code for each option.

In my experience changing too many things in quick succession is not helpful for debugging. One needs to have a hypothesis about what is the cause of the problem followed by a change (in hardware or software) that tests that hypothesis.

...R