Controlling a servo..?

Hello everyone, I'm an arduino noob and i'm working on a project for school, I want to control the rotation of a servo with an app on my phone, so I set the output value from 0 to 180 to control the angle of rotation and I wrote this :

I'd like to know if it's gonna work ? I mean if i output the values 45 then 90 then 45 on my app, will the servo go to the position 45° then 90° then 45° or is my code false ? (I made something similar to the app we can see in this video controlling a servo motor from android phone - YouTube and I don't have the components yet so I can't test it !)
Thanks for your help, any criticism is appreciated ! :slight_smile:

I'd like to know if it's gonna work ?

That depends on HOW the sending application sends the data. It depends on whether the servo is wired, and powered, correctly.

Running an infinite loop (while(1)) inside an infinite loop (loop()) is not the mark of the sharpest crayon in the box.

Well I don't fully understand all the code I posted, I started coding this year and I have never used c/c++, I was given the code a friend used to control servos for an old school project and i rewrote this part, do you mean that the first line already starts an infinite loop and I don't have to start an infinite loop with the while(1) line ? :slight_smile:

I don't have the components yet so I can't test it !

Do you have an arduino?

I will have it once the school has received it (we decided to buy an arduino uno for this project)

You may be interested in this RemoteXY Thread.