color sensor and motor program

Hi so I'm trying to program a robot that uses a color sensor and moves. I tried putting together two programs (one for the color sensor and one for the motors) that work separately but but it didn't work.

I got this error:

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

program_1:64:13: error: expected constructor, destructor, or type conversion before '(' token
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
^
program_1:65:15: error: expected constructor, destructor, or type conversion before '(' token
digitalWrite(9, LOW); //Disengage the Brake for Channel A
^
program_1:66:14: error: expected constructor, destructor, or type conversion before '(' token
analogWrite(3, 225); //Spins the motor on Channel A at full speed
^
program_1:69:16: error: expected constructor, destructor, or type conversion before '(' token
digitalWrite(13, LOW); //Establishes forward direction of Channel A
^
program_1:70:15: error: expected constructor, destructor, or type conversion before '(' token
digitalWrite(8, LOW); //Disengage the Brake for Channel A
^
program_1:71:15: error: expected constructor, destructor, or type conversion before '(' token
analogWrite (11, 225); //Spins the motor on Channel A at full speed
^
program_1:72:1: error: expected declaration before '}' token
}
^
exit status 1
expected constructor, destructor, or type conversion before '(' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I am using an adafruit temperature sensor and two DC motors connected to the motor shield.

My code is:

#include <Wire.h>
#include "Adafruit_TCS34725.h"

/* Example code for the Adafruit TCS34725 breakout library */

/* Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground */

/* Initialise with default values (int time = 2.4ms, gain = 1x) */
// Adafruit_TCS34725 tcs = Adafruit_TCS34725();

/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);

void setup() {
// put your setup code here, to run once:

// color sensor
Serial.begin(9600);

if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1);
}

//MOTOR A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin

//MOTOR B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin

}

void loop() {

//color sensor

uint16_t r, g, b, c, colorTemp, lux;

tcs.getRawData(&r, &g, &b, &c);
// colorTemp = tcs.calculateColorTemperature(r, g, b);
colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
lux = tcs.calculateLux(r, g, b);

Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
Serial.println(" ");
}

// Motor A backward
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 225); //Spins the motor on Channel A at full speed

//Motor B forwards
digitalWrite(13, LOW); //Establishes forward direction of Channel A
digitalWrite(8, LOW); //Disengage the Brake for Channel A
analogWrite (11, 225); //Spins the motor on Channel A at full speed
}

You have a misplaced curly bracket that closes loop() early leaving the rest of the code outside of a function. Use the IDE autoformat tool (ctrl-t or Tools, Auto Formatto see where the mistake is.

      Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
   Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
   Serial.println(" ");
}  // <-------------------------------------------misplaced bracket

// Motor A backward
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW);   //Disengage the Brake for Channel A
analogWrite(3, 225);   //Spins the motor on Channel A at full speed

This is after autoformat. Note how the digitalWrites are up against the left margin. They should be indented.

Deleted that misplaced bracket and the code compiles without errors or warnings.

PLEASE read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code in code tags.