Go Down

Topic: My Servo won't move [SOLVED] (Read 7939 times) previous topic - next topic


Code: [Select]
     Serial.print("Raw value: ");
     Serial.print("Servo angle: ");

number is a float. By default, floats are printed to two decimal places. You need an optional 2nd argument to get more (or less) than 2 decimal places.
The art of getting good answers lies in asking good questions.


Well, that would do it. Any other ideas about the servo?


If the sweep example works then the hardware should be OK. I can't see any reason why the sketch shouldn't move the servo to the angle it is printing out, so there's a faulty assumption here somewhere.

I suggest you take a copy of the sketch and replace the whole of loop() with something like this:

Code: [Select]

void loop()
 sVal = 134;
 Serial.print("Servo angle: ");

If everything works as we assume, the sketch should move the servo to angle 90, wait five seconds and then move it to angle 134. It will also print out a message to show that it has done it. Does it print out the message? Does the servo move as expected?
I only provide help via the forum - please do not contact me for private consultancy.


Ok, I tried what you said, the servo moves as expected, and the message prints just fine. Now I will try bringing back the servo related bits of the void loop and see what happens.


Got it working, it had to do with the fact that sVal was assigning improperly due to being an integer. I mad sVal a float, and it started working, but I had to type cast sVal to int in the myservo.write statement.


I had to type cast sVal to int in the myservo.write statement.

You didn't have to, but it would do no harm.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


You didn't have to, but it would do no harm.

Hmm, well it didn't work before I type cast it. Oh well, it works. Anyway, thanks guys for all the help!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131