So I am trying to control 3 small VEX servos using an IR remote control. Two of the motors actually drive the machine, while the third controls a pulley system that only needs to go back and forth.
To my untrained eye all the code looks fine, but keep on getting this error code:
error: expected unqualified-id before '{' token
So if any of y'all see anything that could fix it, please let me know. I will be grateful for your input.
#include <Servo.h>
Servo servoLeft;
Servo servoRight;
Servo servolift;
const int ServoRightPin = 13;
const int ServoLeftPin = 12;
const int ServoLiftPin = 11;
const int IrDetPin = 10;
const byte ChUp = 16;
const byte ChDn = 17;
const byte VolUp = 18;
const byte VolDn = 19;
const byte Power = 21;
int irPulse;
int CurrentRemoteCode;
int PreviousRemoteCode=5;
int debug =1;
int defaultDelay= 20;
void setup()
{
Serial.begin(9600);
servoLeft.attach(ServoLeftPin);
servoRight.attach(ServoRightPin);
servolift.attach(ServoLiftPin);
pinMode(IrDetPin, INPUT);
servoLeft.writeMicroseconds(1500);
servoRight.writeMicroseconds(1500);
servolift.writeMicroseconds(1500);
}
void maneuver1(int speedlift, int msTime);
{ //line 37
servolift.writeMicroseconds(1500 + speedLeft);
if(msTime==-1)
{
servolift.detach();
}
delay(msTime);
}
void maneuver2(int speedLeft, int speedRight, int msTime);
{
servoLeft.writeMicroseconds(1500 + speedLeft);
servoRight.writeMicroseconds(1500 - speedRight);
if(msTime==-1)
{
servoLeft.detach();
servoRight.detach();
}
delay(msTime);
}
void loop()
{
CurrentRemoteCode=GetIrCode();
if (debug ==1) {
Serial.print("key pressed: ");
Serial.println(CurrentRemoteCode);
}
if (CurrentRemoteCode != PreviousRemoteCode) {
PreviousRemoteCode = CurrentRemoteCode;
Obey(CurrentRemoteCode);
}
}
void Obey(int command) {
switch(command)
{
case 2:
case ChUp:
maneuver2(200, 200, defaultDelay);
break;
case 4:
case VolDn:
maneuver2(-200, 200, defaultDelay);
break;
case 6:
case VolUp:
maneuver2(200, -200, defaultDelay);
break;
case 8:
case ChDn:
maneuver2(-200, -200, defaultDelay);
break;
default:
maneuver2(0, 0, defaultDelay);
}
}
void Obey(int command) {
switch(command)
{
case 1:
maneuver1(200, defaultDelay);
break;
case 3:
maneuver1(-200, defaultDelay);
break;
default:
maneuver1(0, defaultDelay);
}
}
int GetIrCode(){
unsigned long irPulse = -1;
int irCode = 0;
while(pulseIn(IrDetPin, LOW) < 2200) {
}
for(int i = 0; i <= 6; i++)
{
irPulse = pulseIn(IrDetPin, LOW, 2000);
if((irPulse > 1000) && (irPulse < 1400)) bitSet(irCode, i);
}
if(irCode <= 9) irCode++;
if(irCode == 10) irCode = 0;
return irCode;
}