how to add number to a value that i do not know

My project is a bluetooth controlled car.
I want to add a certain value to number that i dont know.
For example i want to add 25 to the motorspeed when bluetooth receive number 13.
My problem is that i cannot add a value because the number could be either 125 or 175 or 200.
i want this code so that the left motors will receive more power when turning to the right.

#include <AFMotor.h>
#include <Servo.h>
char data = 0;
Servo servo1;
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
int led1 = 14;
int led2 = 15;
int led3 = 16;

void setup() {
 Serial.begin(9600); 
 motor1.setSpeed(55);
 motor2.setSpeed(55);
 motor3.setSpeed(55);
 motor4.setSpeed(55);
 motor1.run(RELEASE);
 motor2.run(RELEASE);
 motor3.run(RELEASE);
 motor4.run(RELEASE);
 servo1.attach(9);
}

void loop() {
 data = Serial.read();
 Serial.print(data);
 if(data == 7 ){
  motor1.setSpeed(125);
  motor2.setSpeed(125);
  motor3.setSpeed(125);
  motor4.setSpeed(125);
 }
 if(data == 8 ){
  motor1.setSpeed(175);
  motor2.setSpeed(175);
  motor3.setSpeed(175);
  motor4.setSpeed(175);
 }
 if(data == 9 ){
  motor1.setSpeed(200);
  motor2.setSpeed(200);
  motor3.setSpeed(200);
  motor4.setSpeed(200);
 }
 if(data == 1 ){
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
 }
 if(data == 2 ){
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  digitalWrite(led3, HIGH);
  delay(500);
  digitalWrite(led3, LOW);
  digitalWrite(led2, HIGH); 
 }
 if(data == 3 ){
  motor1.run(BRAKE);
  motor2.run(BRAKE);
  motor3.run(BRAKE);
  motor4.run(BRAKE);
  digitalWrite(led3, HIGH);  
 }
 if(data == 0 ){
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
 }
 if(data == 4 ){
  servo1.write(85);
  delay(5);
  servo1.write(80);
  delay(5);
  servo1.write(75);
  delay(5);
  servo1.write(70);
  delay(5);
  servo1.write(65);
  delay(5);
  servo1.write(60);
  delay(5);
  servo1.write(55);
  delay(5);
  servo1.write(50);
  delay(5);
  servo1.write(45);
  delay(5);
 }
 if(data == 5 ){
  servo1.write(95);
  delay(5);
  servo1.write(100);
  delay(5);
  servo1.write(105);
  delay(5);
  servo1.write(110);
  delay(5);
  servo1.write(115);
  delay(5);
  servo1.write(15);
  delay(5);
  servo1.write(15);
  delay(5);
  servo1.write(130);
  delay(5);
  servo1.write(135);
  delay(5);
 }
  if(data == 6 ){
  servo1.write(90);
 }
  if(data == 10 ){
  digitalWrite(led1, HIGH);
 }
 if(data == 11 ){
  digitalWrite(led1, LOW);
 }
 if(data == 12 ){
  motor2.run(FORWARD);
  motor4.run(FORWARD);
  motor1.run(BRAKE);
  motor3.run(BRAKE);  
 }
}

My problem is that i cannot add a value because the number could be either 125 or 175 or 200.

Why is not knowing the current value a problem?

   int someVal = setBySomeFunctionThatIDontOwnSoIDontKnowTheValue();

   someVal = someVal + 25;

Now, you clearly can not add a value to a constant that was discarded when the function/block ended, so stop using constants.

Define an array of speeds, and set the nth motor's speed to the nth element of the speed array. Then, you CAN increment the value in the array.

You have bigger problems than the one you posed

Consider these 3 lines of your code

char data = 0;
  data = Serial.read();
  if (data == 8 )

So, data is a char which you read from Serial. So far, so good but then you test whether it is equal to an integer such as 8, which it never will be. You should test it against a char like this

  if (data == '8' )

Printing the value of data is a good idea but the print functions can tell the difference between 8 and ‘8’ and act accordingly by printing an 8 in both cases which will mislead you.

(UKHELIBOB) I have changed my code but any number above 9 didn't change blue.Is there any problems caused by that?

(PaulS) I am a beginner so I can't really understand much.Can you give a small example based on my code (I did check the arduino example but it is mostly about led)

Thanks for the reply.

Suren-711:
I want to add a certain value to number that i dont know.
For example i want to add 25 to the motorspeed when bluetooth receive number 13.

In any programming language you use variables to store numbers (and other things - but let's keep it simple). You can add something to the value in a variable without knowing the value in the variable. For example

motorSpeed = motorSpeed + 13;

if motor speed was 65 it will now be 78. If it was 189 it will now be 202.

You can use Serial.print(motorSpeed); if you need to check the value.

...R

I have changed my code but any number above 9 didn't change blue.Is there any problems caused by that?

If you mean the colour of text withing the IDE editor then ignore it.

The colour coding is a waste of time because any library can flag that any keyword should be one of several colours which are applied whether or not the library is actually #included in the sketch

I got an error saying motorspeed was not declared in this scope.
By the way i want to increase the speed of a certain motor and not all.

Post your code otherwise we are working in the datk

#include <AFMotor.h>
#include <Servo.h>
char data = 0;
Servo servo1;
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
int led1 = 14;
int led2 = 15;
int led3 = 16;

void setup() {
 Serial.begin(9600); 
 motor1.setSpeed(55);
 motor2.setSpeed(55);
 motor3.setSpeed(55);
 motor4.setSpeed(55);
 motor1.run(RELEASE);
 motor2.run(RELEASE);
 motor3.run(RELEASE);
 motor4.run(RELEASE);
 servo1.attach(9);
}

void loop() {
 data = Serial.read();
 Serial.print(data);
 if(data == '7' ){
  motor1.setSpeed(150);
  motor2.setSpeed(150);
  motor3.setSpeed(150);
  motor4.setSpeed(150);
 }
 if(data == '8' ){
  motor1.setSpeed(175);
  motor2.setSpeed(175);
  motor3.setSpeed(175);
  motor4.setSpeed(175);
 }
 if(data == '9' ){
  motor1.setSpeed(200);
  motor2.setSpeed(200);
  motor3.setSpeed(200);
  motor4.setSpeed(200);
 }
 if(data == '1' ){
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
 }
 if(data == '2' ){
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  digitalWrite(led3, HIGH);
  delay(500);
  digitalWrite(led3, LOW);
  digitalWrite(led2, HIGH); 
 }
 if(data == '3' ){
  motor1.run(BRAKE);
  motor2.run(BRAKE);
  motor3.run(BRAKE);
  motor4.run(BRAKE);
  digitalWrite(led3, HIGH);  
 }
 if(data == '0' ){
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
 }
 if(data == '4' ){
  servo1.write(85);
  delay(5);
  servo1.write(80);
  delay(5);
  servo1.write(75);
  delay(5);
  servo1.write(70);
  delay(5);
  servo1.write(65);
  delay(5);
  servo1.write(60);
  delay(5);
  servo1.write(55);
  delay(5);
  servo1.write(50);
  delay(5);
  servo1.write(45);
  delay(5);
  motorspeed = motorspeed + 25
 }
 if(data == '5' ){
  servo1.write(95);
  delay(5);
  servo1.write(100);
  delay(5);
  servo1.write(105);
  delay(5);
  servo1.write(110);
  delay(5);
  servo1.write(115);
  delay(5);
  servo1.write(15);
  delay(5);
  servo1.write(15);
  delay(5);
  servo1.write(130);
  delay(5);
  servo1.write(135);
  delay(5);
 }
  if(data == '6' ){
  servo1.write(90);
 }
  if(data == '10' ){
  digitalWrite(led1, HIGH);
 }
 if(data == '11' ){
  digitalWrite(led1, LOW);
 }
 if(data == '12' ){
  motor2.run(FORWARD);
  motor4.run(FORWARD);
  motor1.run(BRAKE);
  motor3.run(BRAKE);  
 }
}

Suren-711:
I got an error saying motorspeed was not declared in this scope.

That is not surprising as you have not defined a variable called motorSpeed at the top of your program. After the line

int led3 = 16;

add the line

int motorSpeed = 0;

I can't tell from your code if you plan to add references to motorSpeed in several other parts of your program, but I hope you do. Otherwise your line motorspeed = motorspeed + 25 will be meaningless.

Note also that every line of code must be terminated with a ; unless it is terminated with a { or }

Without seeing how you propose to use the variable motorSpeed I can't comment on your statement about only varying the speed of one motor.

...R