Hi everyone,
I'm new to arduino and I'm trying to make a robotic arm.
I get this error and I just can't find the problem.
exit status 1
expected ';' before '{' token
#include <Servo.h>
const int xAs1 = A0;
const int yAs1 = A1;
const int xAs2 = A2;
const int yAs2 = A3;
int positionxAs1 = 0;
int positionyAs1 = 0;
int positionxAs2 = 0;
int positionyAs2 = 0;
int servoValue1 = 90;
int servoValue2 = 90;
int servoValue3 = 90;
Servo servo1;
Servo servo2;
Servo servo3;
void setup() {
pinMode(xAs1, INPUT);
pinMode(yAs1, INPUT);
pinMode(xAs2, INPUT);
pinMode(yAs2, INPUT);
pinMode(9, OUTPUT);
servo1.attach(5);
servo1.write(servoValue1);
servo2.attach(6);
servo2.write(servoValue2);
servo3.attach(3);
servo3.write(servoValue3);
}
void loop() {
servoValue1 = map(positionyAs1, 0, 1023, 0, 180);
servoValue2 = map(positionyAs2, 0, 1023, 0, 180);
servoValue3 = map(positionxAs2, 0, 1023, 0, 180);
dcMotorValue(xAs1);
sensorReading1(yAs1);
sensorReading2(xAs2);
sensorReading3(yAs2);
delay(100);
}
void dcMotorValue(int Position) {
positionxAs1 = analogRead(xAs1);
if (Position >= 400 && Position <= 620) {
digitalWrite (9, LOW);
}
else ((Position >=0 && Position <= 399) || (Position >= 621 && Position <= 1023)) {
digitalWrite (9, HIGH);
}
}
void sensorReading1(const int Position) {
positionyAs1 = analogRead(yAs1);
if (Position >= 500 && Position <= 520) {
digitalWrite (servoValue1);
}
else ((Position >= 450 && Position <= 499) || (Position >= 521 && Position <= 570)) {
digitalWrite (servoValue + 1);
}
else ((Position >= 400 && Position <= 449) || (Position >= 571 && Position <= 620)) {
digitalWrite (servoValue1 + 2);
}
else ((Position >= 350 && Position <= 399) || (Position >= 621 && Position <= 670)) {
digitalWrite (servoValue1 + 3);
}
else ((Position >= 300 && Position <= 349) || (Position >= 671 && Position <= 720)) {
digitalWrite (servoValue1 + 4);
}
else ((Position >= 250 && Position <= 299) || (Position >= 721 && Position <= 770)) {
digitalWrite (servoValue1 + 5);
}
else ((Position >= 200 && Position <= 249) || (Position >= 771 && Position <= 820)) {
digitalWrite (servoValue1 + 6);
}
else ((Position >= 150 && Position <= 199) || (Position >= 821 && Position <= 870)) {
digitalWrite (servoValue1 + 7);
}
else ((Position >= 100 && Position <= 149) || (Position >= 871 && Position <= 920)) {
digitalWrite (servoValue1 + 8);
}
else ((Position >= 50 && Position <= 99) || (Position >= 921 && Position <= 970)) {
digitalWrite (servoValue1 + 9);
}
else ((Position >= 0 && Position <= 49) || (Position >= 971 && Position <= 1023)) {
digitalWrite (servoValue1 + 10);
}
}
void sensorReading2(const int Position) {
positionxAs2 = analogRead(xAs2);
if (Position >= 500 && Position <= 520) {
digitalWrite (servoValue2);
}
else ((Position >= 450 && Position <= 499) || (Position >= 521 && Position <= 570)) {
digitalWrite (servoValue2 + 1);
}
else ((Position >= 400 && Position <= 449) || (Position >= 571 && Position <= 620)) {
digitalWrite (servoValue2 + 2);
}
else ((Position >= 350 && Position <= 399) || (Position >= 621 && Position <= 670)) {
digitalWrite (servoValue2 + 3);
}
else ((Position >= 300 && Position <= 349) || (Position >= 671 && Position <= 720)) {
digitalWrite (servoValue2 + 4);
}
else ((Position >= 250 && Position <= 299) || (Position >= 721 && Position <= 770)) {
digitalWrite (servoValue2 + 5);
}
else ((Position >= 200 && Position <= 249) || (Position >= 771 && Position <= 820)) {
digitalWrite (servoValue2 + 6);
}
else ((Position >= 150 && Position <= 199) || (Position >= 821 && Position <= 870)) {
digitalWrite (servoValue2 + 7);
}
else ((Position >= 100 && Position <= 149) || (Position >= 871 && Position <= 920)) {
digitalWrite (servoValue2 + 8);
}
else ((Position >= 50 && Position <= 99) || (Position >= 921 && Position <= 970)) {
digitalWrite (servoValue2 + 9);
}
else ((Position >= 0 && Position <= 49) || (Position >= 971 && Position <= 1023)) {
digitalWrite (servoValue2 + 10);
}
}
void sensorReading3(const int Position) {
positionyAs2 = analogRead(yAs2);
if (Position >= 500 && Position <= 520) {
digitalWrite (servoValue3);
}
else ((Position >= 450 && Position <= 499) || (Position >= 521 && Position <= 570)) {
digitalWrite (servoValue3 + 1);
}
else ((Position >= 400 && Position <= 449) || (Position >= 571 && Position <= 620)) {
digitalWrite (servoValue3 + 2);
}
else ((Position >= 350 && Position <= 399) || (Position >= 621 && Position <= 670)) {
digitalWrite (servoValue3 + 3);
}
else ((Position >= 300 && Position <= 349) || (Position >= 671 && Position <= 720)) {
digitalWrite (servoValue3 + 4);
}
else ((Position >= 250 && Position <= 299) || (Position >= 721 && Position <= 770)) {
digitalWrite (servoValue3 + 5);
}
else ((Position >= 200 && Position <= 249) || (Position >= 771 && Position <= 820)) {
digitalWrite (servoValue3 + 6);
}
else ((Position >= 150 && Position <= 199) || (Position >= 821 && Position <= 870)) {
digitalWrite (servoValue3 + 7);
}
else ((Position >= 100 && Position <= 149) || (Position >= 871 && Position <= 920)) {
digitalWrite (servoValue3 + 8);
}
else ((Position >= 50 && Position <= 99) || (Position >= 921 && Position <= 970)) {
digitalWrite (servoValue3 + 9);
}
else ((Position >= 0 && Position <= 49) || (Position >= 971 && Position <= 1023)) {
digitalWrite (servoValue3 + 10);
}
}