exit status 1

Hi guys, i am currently working on a simple line following and obstacle avoidance robot for my science fair project and i can’t understand why am i getting error message :
Arduino: 1.8.1 (Windows 7), Board: “Arduino/Genuino Uno”

exit status 1
expected unqualified-id before ‘{’ token

On the code

#include <AFMotor.h>
#include <QTRSensors.h>
#include <NewPing.h> //add Ultrasonic sensor library

AF_DCMotor motor1(1, MOTOR12_8KHZ );
AF_DCMotor motor2(2, MOTOR12_8KHZ );

#define trigPin 12 // define the pins of your sensor
#define echoPin 13
#define KP .2
#define KD 5
#define M1_minumum_speed 150
#define M2_minumum_speed 150
#define M1_maksimum_speed 200
#define M2_maksimum_speed 200
#define MIDDLE_SENSOR 4
#define NUM_SENSORS 5
#define TIMEOUT 2500
#define EMITTER_PIN 2
#define DEBUG 0
#define MAX_DISTANCE 100

NewPing sonar(trigPin, echoPin, MAX_DISTANCE);
QTRSensorsRC qtrrc((unsigned char) { A4,A3,A2,A1,A0} ,NUM_SENSORS, TIMEOUT, EMITTER_PIN);

unsigned int sensorValues[NUM_SENSORS];

void setup()
{
delay(1500);
manual_calibration();
set_motors(0,0);
}

int lastError = 0;
int last_proportional = 0;
int integral = 0;

void loop()
{

unsigned int sensors[5];
int position = qtrrc.readLine(sensors);
int error = position - 2000;

int motorSpeed = KP * error + KD * (error - lastError);
lastError = error;

int leftMotorSpeed = M1_minumum_speed + motorSpeed;
int rightMotorSpeed = M2_minumum_speed - motorSpeed;

// set motor speeds using the two motor speed variables above
set_motors(leftMotorSpeed, rightMotorSpeed);
}
{
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);

delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance <10)
motor1.run(RELEASE);
motor2.run(RELEASE);
delay(200)
motor1.run(FORWARD);
motor2.run(BACKWARD);
delay(500)
motor1.run(FORWARD);
motor2.run(FORWARD);
delay(2000)
motor1.run(BACKWARD);
motor2.run(FORWARD);
delay(550)
motor1.run(FORWARD);
motor2.run(FORWARD);
delay(600)
}

void set_motors(int motor1speed, int motor2speed)
{
if (motor1speed > M1_maksimum_speed ) motor1speed = M1_maksimum_speed;
if (motor2speed > M2_maksimum_speed ) motor2speed = M2_maksimum_speed;
if (motor1speed < 0) motor1speed = 0;
if (motor2speed < 0) motor2speed = 0;
motor1.setSpeed(motor1speed);
motor2.setSpeed(motor2speed);
motor1.run(FORWARD);
motor2.run(FORWARD);
}

void manual_calibration() {

int i;
for (i = 0; i < 250; i++){

qtrrc.calibrate(QTR_EMITTERS_ON);
delay(20);
}

if (DEBUG) {

Serial.begin(9600);

for (int i = 0; i < NUM_SENSORS; i++){

Serial.print(qtrrc.calibratedMinimumOn*);*

  • Serial.print(’ ');*
    }

  • Serial.println();*

  • for (int i = 0; i < NUM_SENSORS; i++){*

_ Serial.print(qtrrc.calibratedMaximumOn*);_
_
Serial.print(’ ');_
_
}_
_
Serial.println();_
_
Serial.println();_
_
}_
_
}*_
Please help me sort out this problem as soon as possible.

Is half of your code really in italics? That's going to cause an error for sure. Oh, you didn't read the post on how to use this forum? That explains why you don't know what code tags are. I would appreciate it if you would read that before posting anymore.

It looks like you have a } closing the loop function and then have a whole bunch of code that isn't in a function. You need to pay particular attention to where the { and } go in your code.

void loop()
{
 
  unsigned int sensors[5];
  int position = qtrrc.readLine(sensors);
  int error = position - 2000;
 
  int motorSpeed = KP * error + KD * (error - lastError);
  lastError = error;
 
  int leftMotorSpeed = M1_minumum_speed + motorSpeed;
  int rightMotorSpeed = M2_minumum_speed - motorSpeed;
 
  // set motor speeds using the two motor speed variables above
  set_motors(leftMotorSpeed, rightMotorSpeed);
}  <<---loop() ends here
{ <<---Oops