Society of Robots - Robot Forum

Software => Software => Topic started by: offy on March 30, 2009, 09:13:20 AM

Title: Stop a servo
Post by: offy on March 30, 2009, 09:13:20 AM
I need help with a servo I have. well all of them. They are modifyed HS-311 servos. I can get them to go forward and back (135, 45) but how can I get one to stop. I have this code, please help.

Code: [Select]
#include <Servo.h>
Servo wheel;
int value = 0;
int treshold = 300;
void setup()
{
  wheel.attach(9);
}
void loop()
{
  value = analogRead(0);
  if (value < treshold)
  {
    move();
  }
  else
  {
    stop();
  }
}
void stop ()
{
}
void move ()
{
  wheel.write(135);
}


I tried wheel.write(0) but it still kept on going.
Title: Re: Stop a servo
Post by: Razor Concepts on March 30, 2009, 10:07:00 AM
90 should be center, 180 is one extreme (left) 0 is the other extreme (right). So try wheel.write(90) and that should be close to center.
Title: Re: Stop a servo
Post by: offy on March 30, 2009, 11:16:39 AM
Thanks, it ended up to be 95. But still all good. Thanks much. Soon I hope to add my little robot thing to the member pages.