Code Example

void PrintRC()
{ // print out the values you read in:
  Serial.println(" RC Control Mode ");
  Serial.print("Value Ch1 = ");
  Serial.println(Ch1);
  Serial.print("Value Ch2 = ");
  Serial.println(Ch2);
  Serial.print("Value Ch3 = ");
  Serial.println(Ch3);
  Serial.print("Value Ch4 = ");
  Serial.println(Ch4);
  Serial.print("Control = ");
  Serial.println(Ch5);
  Serial.print("Value Ch6 = ");
  Serial.println(Ch6);
  Serial.println(" ");

  if (Ch2 > Ch2_Upper_Trigger) {
    Ch2 = map(Ch2, Ch2_Upper_Trigger, 1900, Ch2_Upper_Trigger, Ch2_Max_Value);

    if (Ch1 < Ch1_Upper_Trigger && Ch1 > Ch1_Lower_Trigger) {
      Serial.println("L_DCMotor = " + String(Ch2)); // sets the servo position
      Serial.println("R_DCMotor = " + String(Ch2)); // Set so that stearing would be horz stick
    }

    if (Ch1 > Ch1_Upper_Trigger) {
      Serial.println("L_DCMotor = " + String(Ch2)); // Set so that stearing would be horz stick
      CalcHold = Ch1;
      CalcHold = map(CalcHold, Ch1_Upper_Trigger, 1900, -50, -300);//    map(value, fromLow, fromHigh, toLow, toHigh)
      Serial.println("Change Right Wheel by " + String(CalcHold));
      Serial.println("R_DCMotor = " + String(Ch2 + CalcHold)); // sets the servo position
    }

    if (Ch1 < Ch1_Lower_Trigger) {
      Serial.println("L_DCMotor = " + String(Ch2)); // Set so that stearing would be horz stick
      CalcHold = Ch1;
      CalcHold = map(CalcHold, Ch1_Lower_Trigger, 1000, 50, 300);//    map(value, fromLow, fromHigh, toLow, toHigh)
      Serial.println("Change Right Wheel by " + String(CalcHold));
      Serial.println("R_DCMotor = " + String(Ch2 + CalcHold)); // sets the servo position
    }
  }
  
  if (Ch2 < Ch2_Lower_Trigger) {
    Ch2 = map(Ch2, Ch2_Lower_Trigger, 1000, Ch2_Lower_Trigger, Ch2_Min_Value);
    
    if (Ch1 < Ch1_Upper_Trigger && Ch1 > Ch1_Lower_Trigger) {
      Serial.println("L_DCMotor = " + String(Ch2)); // sets the servo position
      Serial.println("R_DCMotor = " + String(Ch2)); // Set so that stearing would be horz stick
    }

    if (Ch1 > Ch1_Upper_Trigger) {
      Serial.println("L_DCMotor = " + String(Ch2)); // Set so that stearing would be horz stick
      CalcHold = Ch1;
      CalcHold = map(CalcHold, Ch1_Upper_Trigger, 1900, -50, -300);//    map(value, fromLow, fromHigh, toLow, toHigh)
      Serial.println("Change Right Wheel by " + String(CalcHold));
      Serial.println("R_DCMotor = " + String(Ch2 + CalcHold)); // sets the servo position
    }

    if (Ch1 < Ch1_Lower_Trigger) {
      Serial.println("L_DCMotor = " + String(Ch2)); // Set so that stearing would be horz stick
      CalcHold = Ch1;
      CalcHold = map(CalcHold, Ch1_Lower_Trigger, 1000, 50, 300);//    map(value, fromLow, fromHigh, toLow, toHigh)
      Serial.println("Change Right Wheel by " + String(CalcHold));
      Serial.println("R_DCMotor = " + String(Ch2 + CalcHold)); // sets the servo position
    }
  }

  Serial.println(" ");
  delay(1000);
}