Code problems, help!

O, I am using this code and I am having an error message "Expected unquallified-id on line 28

#include <RedBot.h>
RedBotSensor left = RedBotSensor(A3); // initialize a left sensor object on A3
RedBotSensor center = RedBotSensor(A6); // initialize a center sensor object on A6
RedBotSensor right = RedBotSensor(A7); // initialize a right sensor object on A7

// constants that are used in the code. LINETHRESHOLD is the level to detect
// if the sensor is on the line or not. If the sensor value is greater than this
// the sensor is above a DARK line.
//
// SPEED sets the nominal speed

#define LINETHRESHOLD 800
#define SPEED 60 // sets the nominal speed. Set to any number from 0 - 255.

RedBotMotors motors;
int leftSpeed; // variable used to store the leftMotor speed
int rightSpeed; // variable used to store the rightMotor speed

void setup()
{
Serial.begin(9600);
Serial.println("Welcome to experiment 6.2 - Line Following");
Serial.println("------------------------------------------");
delay(2000);
Serial.println("IR Sensor Readings: ");
delay(500);
}
{ irDetectLeft; VAR; Bit ' Left IR reading;
irDetectRight; VAR; Bit ' Right IR reading;
pulseLeft VAR Word ' pulse values for servos
pulseRight VAR Word
' -----[ Initialization ]----------------------------------------------
DEBUG "Program Running!"
FREQOUT 4, 2000, 3000 ' Signal start/reset.
' -----[ Main Routine ]------------------------------------------------
Main:
' Spin around slowly until an object is spotted
DO
PULSOUT 13, 790 ' Rotate slowly
PULSOUT 12, 790
PAUSE 15 ' 5 ms for detectors
GOSUB Check_IRs ' While looking for object
LOOP UNTIL (irDetectLeft = 0) OR (irDetectRight = 0)
' Now figure out exactly where the object is and go toward it
DO
' Object in both detectors -- go forward
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 850 ' Forward
pulseRight = 650
' Object on left - go left
ELSEIF (irDetectLeft = 0) THEN
pulseLeft = 650 ' Left toward object
pulseRight = 650
' Object on right - go right
ELSEIF (irDetectRight = 0) THEN
pulseLeft = 850 ' Right toward object
pulseRight = 850
' No object -- go forward anyway, because the detectors will
ELSE ' momentarily show
pulseLeft = 850 ' "no object" as the
pulseRight = 650 ' Boe-Bot is adjusting
ENDIF ' its position.
PULSOUT 13,pulseLeft ' Apply the pulse.
PULSOUT 12,pulseRight
PAUSE 15 ' 5 ms for detectors
' Check IRs again in case object is moving
GOSUB Check_IRs
LOOP
' -----[ Subroutines ] ------------------------------------------------
Check_IRs:
FREQOUT 8, 1, 38500 ' Check IR Detectors
irDetectLeft = IN9
FREQOUT 2, 1, 38500
IrDetectRight = IN0
}

void loop()
{

}

You have posted code without using code tags. This creates certain problems and obstacles for other forum members. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the [code] and [/code] metatags.

When you are finished that, please read this post:

How to use this forum - please read.

Most of your code appears to have been copied from a PICBasic program and cannot work on an Arduino.
(Back to the drawing board, I'm afraid. :frowning: )

All C/C++ code must be in a function with a name and a return type.

Furthermore, LOOP, GOSUB, and several other things in this program are not normally acceptable code.

As fine an example of cargo cult programming as I have ever seen.

Cargo Cult Programming
Voodoo Chicken Coding

PaulMurrayCbr:
As fine an example of cargo cult programming as I have ever seen.

Cargo Cult Programming
Voodoo Chicken Coding

Except that "Voodoo Chicken Coding" is defined as code that actually works in the end.

wiki:
This results, typically, in a lot of cut-and-pasting from other code that does something similar, but works; arbitrary reordering of statements; and other tricks.
Eventually, the program works, but there is no understanding of why.

Not much chance of that here. :smiley:
(Most of it would almost work in my PICBasic Pro compiler for PIC chips though, if that counts for anything.)