I have just written my first code in Arduino IDE. The code should make a servo move to 180 degrees wait one second and then move back to 0 degrees and repeat.
Here it is :
#include <Servo.h>
Servo servo1;
int posR = 179;
int posL = 0;
void setup()
{
servo1.attach(9);
}
void loop()
{
{
servo1.write(posR);
delay(1000);
}
{
servo1.write(posL);
delay(1000);
}
}
My question is, do you think my code will do what it's suppose to do I have to change something?
You don’t need those extra brackets you got there in the main loop. The code you show above should only have 2 sqiggily brackets total for the main loop.
The real question is: Why did you ask the question? One great way to confirm if the code will work or not is to put the code into your arduino and see if it works or not. Did it?