Hello,
post the sketch well formated and in code tags.
Ok will do
@collinharm, your topic has been moved to a more suitable location on the forum.
#include<Servo.h>
Servo servo1;
Servo servo2;
int serPos = 0;
int servoPos = 0;
void setup() {
servo1.attach(3);
servo2.attach(5);
}
void loop() {
for(servoPos>=0;servoPos<180; servoPos++)(
{
servo1.write(servoPos);
servo2.write(servoPos);
delay(20);
}
); for(servoPos<=180;servoPos> 0; servoPos--)(
servo1.write(servoPos));
servo2.write(servoPos);
delay(20);
}
}
the error i get is:
\sketch_jun29c:28:1: error: expected declaration before '}' token
}
^
exit status 1
expected declaration before '}' token
Next time, use code tags !! Please read How to get the best out of this forum to find out.
Why do you have a ( at the end of the lines starting with for ? Why do you have randomly placed ) in your code? I think that you have been confused about the use of {} and ()
Here is your code indented with the autoformat tool of the IDE and posted in code tags. The extraneous ')' and ';' are removed and the curly brackets fixed. A feature of the IDE is that if you put the cursor to the right of a {, }, ( or ), the cursor will highlight, what the IDE thinks, is its mate. If the IDE can't find a mate nothing will be highlighted. A clue that something doesn't match.
#include<Servo.h>
Servo servo1;
Servo servo2;
int serPos = 0; // do you need an int for a value that will not exceed 180?
int servoPos = 0;
void setup()
{
servo1.attach(3);
servo2.attach(5);
}
void loop()
{
for (servoPos = 0; servoPos < 180; servoPos++)
{
servo1.write(servoPos);
servo2.write(servoPos);
delay(20);
}
for (servoPos = 180; servoPos > 0; servoPos--)
{
servo1.write(servoPos);
servo2.write(servoPos);
delay(20);
}
}
I got it fixed thank you all for helping a newbie like me out I really appreciate it ![]()
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
