Rc car 2 inputs 1 output

//ESC & Throttle settings
const int forwardMax = 1947;
const int forwardMin = 1470; //throttle Deadband start
const int neutral = 1453; //Center of neutral Deadband
const int reverseMin = 1440; //throttle Deadband end
const int reverseMax = 974;
const int RPWMA = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
const int LPWMA = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)
const int RPWMB = 7; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
const int LPWMB = 8; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)

//Steering Controll
const int SteeinglPin = 2;
const int SteeringLeft = 974;
const int SrteeringCenter= 1453;
const int SteeringRight = 1947;
//Roatating Controll
const int RotateLeftPin = 24;
const int RotateRightPin = 25;
const int RotateLeftMin = 973;
const int RotateLeftMax = 2000;
const int RotateRightMin = 973;
const int RotateRightMax = 2000;
const int RPWMC = 9; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
const int LPWMC = 10; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)

//Remote & Govenor Settings
const int remoteThrottlePin = 3;
const int remoteGovenorPin = 23;
const int framerate = 22000; //in microseconds
const int remoteGovenorHigh = 1947;
const int remoteGovenorMedium = 1453;
const int remoteGovenorLow = 974;

//Park Brake
const int parkeBrakePin = 22;
const int parkeBrakeON = 1947;
const int parkeBrakeOFF = 974;

//Car, Pedal & Forward/Neutral/Reverse switch settings
const int pedalMin = 200; //or176 //my min pedal raw input is about 200 so I set it slightly higer the reduce false pedal input
const int pedalMax = 870; //my max pedal input is about 378
const int pedalGovenor = 100; //percentage
const int pedalPin = A0;
const int forwardPin = 30;
const int reversePin = 31;

int finalpedalInput = 0;
int adjpedalInput = 0;

void setup() {
// Set up serial monitor
Serial.begin(115200);
// Set all pins as INPUTS
pinMode(parkeBrakePin, INPUT);
pinMode(remoteGovenorPin, INPUT);
pinMode(remoteThrottlePin, INPUT);
pinMode(SteeinglPin, INPUT);
pinMode(RotateLeftPin, INPUT);
pinMode(RotateRightPin, INPUT);
//Set Car Pins as INPUT
pinMode(forwardPin, INPUT);
digitalWrite(forwardPin, HIGH);
pinMode(reversePin, INPUT);
digitalWrite(reversePin, HIGH);
//Set Motor Pins as OUTPUT
pinMode(RPWMA, OUTPUT);
pinMode(LPWMA, OUTPUT);
pinMode(RPWMB, OUTPUT);
pinMode(LPWMB, OUTPUT);
pinMode(RPWMC, OUTPUT);
pinMode(LPWMC, OUTPUT);
}

void loop() {

int pwmOutput = neutral;
// Use the Remote input first
int remoteThrottleInput = pulseIn(remoteThrottlePin, HIGH);
if (remoteThrottleInput != 0 && remoteThrottleInput <= reverseMin|| remoteThrottleInput >= forwardMin) {
pwmOutput = remoteThrottleInput;
}

// Is car disabled
else {
int variableGovenor = pulseIn(remoteGovenorPin, HIGH);
int variablePedalGovenor = map (variableGovenor, remoteGovenorLow, remoteGovenorHigh, 0, 100); // map variableGovenor to 1-100
variablePedalGovenor = constrain(variablePedalGovenor, 0, 100);
int pedalInput = analogRead(pedalPin); // = 200-870

// Are we hitting the pedal?
if (pedalInput > pedalMin){
pedalInput = constrain (pedalInput, pedalMin, pedalMax);
adjpedalInput = map(pedalInput, pedalMin, pedalMax, 0, 100); // map pedal input to 1-100
finalpedalInput = adjpedalInput * variablePedalGovenor / 100; // Apply Pedal Govenor to adjpedalInput
finalpedalInput = constrain (finalpedalInput, 0, 100);

// What direction are we going?
bool carForward = digitalRead(forwardPin);
bool carReverse = digitalRead(reversePin);

// Are we going forward?
if (carForward == 0) {
pwmOutput = map(finalpedalInput, 0, 100, forwardMin, forwardMax);
}

// Then are we going backward?
else if (carReverse == 0) {
pwmOutput = map(finalpedalInput, 0, 100, reverseMin, reverseMax);
}
}
// Then we should be in neutral
else {
pwmOutput = neutral;
}
}
//Steering out as pwm
digitalWrite(LPWMC, HIGH);
digitalWrite(RPWMC, HIGH);
delayMicroseconds(pwmOutput);
digitalWrite(LPWMC, LOW);
digitalWrite(RPWMC, LOW);
delayMicroseconds(framerate - pwmOutput);
// Throttle out as pwm
digitalWrite(LPWMA, HIGH);
digitalWrite(RPWMA, HIGH);
digitalWrite(LPWMB, HIGH);
digitalWrite(RPWMB, HIGH);
delayMicroseconds(pwmOutput);
digitalWrite(LPWMA, LOW);
digitalWrite(RPWMA, LOW);
digitalWrite(LPWMB, LOW);
digitalWrite(RPWMB, LOW);
delayMicroseconds(framerate - pwmOutput);

}

As you can see i dont know what im doing, sorry if this is a repetitive post but i would really appreciate some help.
Its a rc ride on with overright function spin and a little more. Only acceleration and steering are pwm the rest is not, im using 3 bts7960 2 for the wheels and 1 for the steering.

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

//ESC & Throttle settings
const int forwardMax = 1947;
const int forwardMin = 1470;  //throttle Deadband start
const int neutral = 1453;     //Center of neutral Deadband
const int reverseMin = 1440;  //throttle Deadband end
const int reverseMax = 974;
const int RPWMA = 5;  // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
const int LPWMA = 6;  // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)
const int RPWMB = 7;  // Arduino PWM output pin 7; connect to IBT-2 pin 1 (RPWM)
const int LPWMB = 8;  // Arduino PWM output pin 8; connect to IBT-2 pin 2 (LPWM)

//Steering Controll
const int SteeinglPin = 2;
const int SteeringLeft = 974;
const int SrteeringCenter = 1453;
const int SteeringRight = 1947;
//Roatating Controll
const int RotateLeftPin = 24;
const int RotateRightPin = 25;
const int RotateLeftMin = 973;
const int RotateLeftMax = 2000;
const int RotateRightMin = 973;
const int RotateRightMax = 2000;
const int RPWMC = 9;   // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
const int LPWMC = 10;  // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)


//Remote & Govenor Settings
const int remoteThrottlePin = 3;
const int remoteGovenorPin = 23;
const int framerate = 22000;  //in microseconds
const int remoteGovenorHigh = 1947;
const int remoteGovenorMedium = 1453;
const int remoteGovenorLow = 974;

//Park Brake
const int parkeBrakePin = 22;
const int parkeBrakeON = 1947;
const int parkeBrakeOFF = 974;

//Car, Pedal & Forward/Neutral/Reverse switch settings
const int pedalMin = 200;      //or176    //my min pedal raw input is about 200 so I set it slightly higer the reduce false pedal input
const int pedalMax = 870;      //my max pedal input is about 378
const int pedalGovenor = 100;  //percentage
const int pedalPin = A0;
const int forwardPin = 30;
const int reversePin = 31;

int finalpedalInput = 0;
int adjpedalInput = 0;

void setup() {
  // Set up serial monitor
  Serial.begin(115200);
  // Set all pins as INPUTS
  pinMode(parkeBrakePin, INPUT);
  pinMode(remoteGovenorPin, INPUT);
  pinMode(remoteThrottlePin, INPUT);
  pinMode(SteeinglPin, INPUT);
  pinMode(RotateLeftPin, INPUT);
  pinMode(RotateRightPin, INPUT);
  //Set Car Pins as INPUT
  pinMode(forwardPin, INPUT);
  digitalWrite(forwardPin, HIGH);
  pinMode(reversePin, INPUT);
  digitalWrite(reversePin, HIGH);
  //Set Motor Pins as OUTPUT
  pinMode(RPWMA, OUTPUT);
  pinMode(LPWMA, OUTPUT);
  pinMode(RPWMB, OUTPUT);
  pinMode(LPWMB, OUTPUT);
  pinMode(RPWMC, OUTPUT);
  pinMode(LPWMC, OUTPUT);
}

void loop() {



  int pwmOutput = neutral;
  // Use the Remote input first
  int remoteThrottleInput = pulseIn(remoteThrottlePin, HIGH);
  if (remoteThrottleInput != 0 && remoteThrottleInput <= reverseMin || remoteThrottleInput >= forwardMin) {
    pwmOutput = remoteThrottleInput;
  }

  //  Is car disabled
  else {
    int variableGovenor = pulseIn(remoteGovenorPin, HIGH);
    int variablePedalGovenor = map(variableGovenor, remoteGovenorLow, remoteGovenorHigh, 0, 100);  // map variableGovenor to 1-100
    variablePedalGovenor = constrain(variablePedalGovenor, 0, 100);
    int pedalInput = analogRead(pedalPin);  //  = 200-870

    // Are we hitting the pedal?
    if (pedalInput > pedalMin) {
      pedalInput = constrain(pedalInput, pedalMin, pedalMax);
      adjpedalInput = map(pedalInput, pedalMin, pedalMax, 0, 100);   // map pedal input to 1-100
      finalpedalInput = adjpedalInput * variablePedalGovenor / 100;  // Apply Pedal Govenor to adjpedalInput
      finalpedalInput = constrain(finalpedalInput, 0, 100);

      // What direction are we going?
      bool carForward = digitalRead(forwardPin);
      bool carReverse = digitalRead(reversePin);

      // Are we going forward?
      if (carForward == 0) {
        pwmOutput = map(finalpedalInput, 0, 100, forwardMin, forwardMax);
      }

      // Then are we going backward?
      else if (carReverse == 0) {
        pwmOutput = map(finalpedalInput, 0, 100, reverseMin, reverseMax);
      }
    }
    // Then we should be in neutral
    else {
      pwmOutput = neutral;
    }
  }
  //Steering out as pwm
  digitalWrite(LPWMC, HIGH);
  digitalWrite(RPWMC, HIGH);
  delayMicroseconds(pwmOutput);
  digitalWrite(LPWMC, LOW);
  digitalWrite(RPWMC, LOW);
  delayMicroseconds(framerate - pwmOutput);
  // Throttle out as pwm
  digitalWrite(LPWMA, HIGH);
  digitalWrite(RPWMA, HIGH);
  digitalWrite(LPWMB, HIGH);
  digitalWrite(RPWMB, HIGH);
  delayMicroseconds(pwmOutput);
  digitalWrite(LPWMA, LOW);
  digitalWrite(RPWMA, LOW);
  digitalWrite(LPWMB, LOW);
  digitalWrite(RPWMB, LOW);
  delayMicroseconds(framerate - pwmOutput);
}

Im trying... thanks for the help.. i was planing ro connect the enable pins of the bts7960 to constant 5v but im thinking it might be helpful for the parkeBrake comand? Any help with this would be much appreciated its all over the place even i can see that and i dont know what im looking at yet

are you using a tutorial? a schematic would be helpful and what microcontroller are you using? how do you steer it?

how do you control it?

Sorry a rc reciver and controller the values in the sketch is what i got following the totorial for the rc controller

But i didnt define bool even though only the steeong and the acceleration are pwm the rest are bool switches on and off

Im using a hotrc ct6b rc transmitter and reciver

Are you running out of pins?

I was with the uno so i bought the mega

Now i have plenty

I don't see a situation where you would want one enabled and the other not enabled, so I would connect both enables together and connect to one Arduino pin.

The exact type of the transmitter and receiver doesn't matter. It is very likely that the receiver is outputting standard RC-servo-signals.

This sounds like you want to connect sometimes

left-left motors
front-left-motor and back-left-motor to one motorcontroller

right-right motors
front-right-motor and back-right-motor to one motorcontroller
and some other time

front-motors (left and right)
front-left-motor and front-right-motor to one motor-controller

back-motors (left and right)
back-left-motor and back-right-motor to one motor-controller

and in this case you should really post a schematic
how you wired all things together.

If you wire it wrong or if you wire it in parallel
and switch on/off the control-inputs unlucky you can create shortcuts and everything will be destroyed

  • your motor-controllers will be destroyed
  • your batteries wil be destroyed or even catching fire

You really really really should post a schematic.

A much better solution will be to use four motor-controllers so each motor-controller is just wired to one single motor and all back / forth / rotating is done by the rotation-direction of each wheel.

You can proceed in two ways in your project.
Trying to saving time by quick assumings and wild testing.
If you use this method you will burn up components and will spend time waiting for new orderd and new payed components

Or investing time to learn how it all works and then proceeding fast step by step through expanding your code step by step.

If your main fun is to fix burned up components go on with wild testing. You will have really a lot of fun.

True i can jump some wires that won't be a problem

I will try and load a schematic as soon as possible. I can always change the pin outputs to suit my needs...

Is the code you posted supposed to be for the transmitter side or receiver side?

If I try to conclude from lines like this

I guess it is the receiver-code reading in the standard-RC-servo-pulse-signals

Yes your correct

All i did was messure the reciver signal for each channel i want to use and wrote them in

You never said what is wrong, what works, doesn't work or if anything works at all. So what other help do you need.