I am trying to control a 24V DC motor position using a single input encoder. The encoder wheel has got 30 spikes on it. It is connected to the interrupt 0 pin. I am trying to move the motor first to a forward position (theta1 = 120deg) from a home position. Then back to the home position from where it has to be moved to a backward position (theta1D = 90deg). I have written a code for the same but while compiling it gives an error on line 6 as
error : expected unqualified-id before '{' token
The code is as shown below:
int encoder1Pin = 2;
int motor1PinA = 3;
int motor1PinB = 4;
volatile int encoder1Pos = 0;
{
void setup ()
{
pinMode(encoder1Pin,INPUT);
pinMode (motor1PinA,OUTPUT);
pinMode (motor1PinB,OUTPUT);
attachInterrupt(0, ISR, CHANGE);
int theta1 = 120;
int theta1D = 90;
}
int motor1Forward();
{
digitalWrite(motor1PinA,HIGH);
{
if(encoder1Pos*6 == theta1);
}
digitalWrite(motor1PinA,LOW);
encoder1Pos = 0;
}
int motor1Home();
{
digitalWrite(motor1PinB,HIGH);
{
if(encoder1Pos*6 == theta1);
}
digitalWrite(motor1PinB,LOW);
encoder1Pos = 0;
}
int motor1Backward();
{
digitalWrite(motor1PinB,HIGH);
{
if(encoder1Pos*6 == theta1D);
}
digitalWrite(motor1PinB,LOW);
encoder1Pos = 0;
}
}
{
void ISR()
{
encoder1Pos++
}
}