trio motor code error

hey everyone, I have to make my own design for school. Me and my friend thought about a submarine, so he designed it and I should write the code, however this isn’t the easiest part. I can’t make a code myself, so I search for a code on internet. I found one at this site:https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/ . It was very helpful, so credits to the guy who made it, but he uses only two motors. We use three motors(two for forward, backward and sides; motor AB, and one for up and down; motor C). so I have to write a code myself. I tried it, but when I did the verify check he gave my some errors. I don’t know what to do right now so maybe you can help me. I would be really grateful.
here’s the code by the way

``````  #define enA 9
#define in1 4
#define in2 5
#define enB 10
#define in3 6
#define in4 7
#define enC 11
#define in5 2
#define in6 3

int motorSpeedA = 0;
int motorSpeedB = 0;
int motorSpeedC = 0;

void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(in5, OUTPUT);
pinMode(in6, OUTPUT);
}

void loop() {

int xAxis = analogRead(A0); // Read Joysticks X-axis
int yAxis = analogRead(A1); // Read Joysticks Y-axis
int zAxis = analogRead(A2); // Read Joysticks Z-axis

analogWrite(enA, motorSpeedA); // Send PWM signal to motor A
analogWrite(enB, motorSpeedB); // Send PWM signal to motor B
analogWrite(enC, motorSpeedC); // Send PWM signal to motor C

// Y-axis used for forward and backward control
if (yAxis < 470) {
// Set Motor A backward
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
// Set Motor B backward
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
// Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedA = map(yAxis, 470, 0, 0, 255);
motorSpeedB = map(yAxis, 470, 0, 0, 255);
}
else if (yAxis > 550) {
// Set Motor A forward
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
// Set Motor B forward
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
// Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedA = map(yAxis, 550, 1023, 0, 255);
motorSpeedB = map(yAxis, 550, 1023, 0, 255);
}
// If joystick stays in middle the motors are not moving
else {
motorSpeedA = 0;
motorSpeedB = 0;
}

// X-axis used for left and right control
if (xAxis < 470) {
// Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value
int xMapped = map(xAxis, 470, 0, 0, 255);
// Move to left - decrease left motor speed, increase right motor speed
motorSpeedA = motorSpeedA - xMapped;
motorSpeedB = motorSpeedB + xMapped;
// Confine the range from 0 to 255
if (motorSpeedA < 0) {
motorSpeedA = 0;
}
if (motorSpeedB > 255) {
motorSpeedB = 255;
}
}
if (xAxis > 550) {
// Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value
int xMapped = map(xAxis, 550, 1023, 0, 255);
// Move right - decrease right motor speed, increase left motor speed
motorSpeedA = motorSpeedA + xMapped;
motorSpeedB = motorSpeedB - xMapped;
// Confine the range from 0 to 255
if (motorSpeedA > 255) {
motorSpeedA = 255;
}
if (motorSpeedB < 0) {
motorSpeedB = 0;
}
// Z-axis used for forward and backward control
if (zAxis < 470) {
// Set Motor c backward
digitalWrite(in5, HIGH);
digitalWrite(in6, LOW);

// Convert the declining Z-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedC = map(zAxis, 470, 0, 0, 255);

}
else if (zAxis > 550) {
// Set Motor C forward
digitalWrite(in5, LOW);
digitalWrite(in6, HIGH);

// Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedC = map(zAxis, 550, 1023, 0, 255);

}
// If joystick stays in middle the motor is not moving
else {
motorSpeedC = 0;
}
``````

and here are the errors:

``````Compiling sketch...
/tmp/990517735/MSS_113_motorABC/MSS_113_motorABC.ino: In function 'void loop()':
/tmp/990517735/MSS_113_motorABC/MSS_113_motorABC.ino:116:7: error: expected '}' at end of input
/tmp/990517735/MSS_113_motorABC/MSS_113_motorABC.ino:116:7: error: expected '}' at end of input
exit status 1
``````

Please go back and edit your post to use code tags for the code.

And please post the "some errors" you got (in code tags). When I verify what you posted the only error I get is missing } at the end.

What Arduino are you compiling it for?

Steve

arduino uno

And have you tried adding a couple of } at the end of input like it suggests?

Checking for balanced brackets {} and () is one of the first things you should do. You must always have the same number of openers { as closers }.

Steve