Author Topic: Stop a servo  (Read 1211 times)

0 Members and 1 Guest are viewing this topic.

Offline offyTopic starter

  • Supreme Robot
  • *****
  • Posts: 340
  • Helpful? 1
Stop a servo
« 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.
« Last Edit: March 30, 2009, 09:57:06 AM by offy »

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: Stop a servo
« Reply #1 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.

Offline offyTopic starter

  • Supreme Robot
  • *****
  • Posts: 340
  • Helpful? 1
Re: Stop a servo
« Reply #2 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.

 


Get Your Ad Here