My first hand written code

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()





void loop()











My question is, do you think my code will do what it's suppose to do I have to change something?

Any help is well appreciated!





Yeah but…

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?


I don’t have my board yet. I’m just asking to see whether it will do it’s job or not. Thnx BTW!

i havent programmed for

i havent programmed for arduino but i think you will need a main loop

Its there…

The main loop is the thing labeled “loop” in his code.

okay thanks, I’m used to

okay thanks, I’m used to doing:

int main(void) {