Best Practice for Holding a Servo at a Set Position.

Hello all,

Now that I have dabbled around a little and learned some things, I decided to work on my first real project.

I am attempting to recreate the motion of the LCD flipping open in the below video.

My question is, what is the best way to hold a servo at a set position? If I use a push button, would holding it down for a long period of time have a negative affect on any thing? Or is there a better way to do this?

Below is a sloppy copy and paste job of the examples, which I assume would work, but should give you an idea of what I am talking about.

const int buttonPin = 2;     
const int ledPin =  13;      
int buttonState = 0;         
#include <Servo.h>
Servo myservo;
void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  myservo.attach(9);
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {
    
    digitalWrite(ledPin, HIGH);
	myservo.write(0);
  } else {
  
    digitalWrite(ledPin, LOW);
	myservo.write(90); 
  }
}

Thank you for your time! :slight_smile:

fodelement:
My question is, what is the best way to hold a servo at a set position? If I use a push button, would holding it down for a long period of time have a negative affect on any thing? Or is there a better way to do this?

I can't see your video because my internet is too slow today.

I wonder if you have asked the wrong question? A servo will stay wherever you tell it to with Servo.write()

I think your question has something to do with how to get the program to detect a button press - but that's really a guess. Have another go at an explanation.

It certainly won't cause a problem for the Arduino if you press a button for years.

...R

One of the cool things about hobby servos. You tell it to go and it goes there.
You want it to stay there, then don't tell it to go somewhere else.

This assumes it has enough torque to be able to move it with whatever load you have on it.
If the servo has to work hard to keep its position, it might overheat. I try to design such things so that mechanically the movement of the linkages locks the moving piece into position and the servo motor does not have to bear (as much of) the force to keep it there.

That video shows the LCD screen flipping up. When it is on the way up, the servo has to lift much of the weight of the screen.
But when the screen is in the full upright position, it looks like most of the weight will be on the hinge and the servo will need very little force to hold it there.

Another concern is on the retract side of things. You tell the servo to lower the screen. if the servo moves a little further than is necessary to lower the screen, it might bind, trying to get the screen lower that the physical limits permit. This also could overheat the servo.

Robin2:
It certainly won't cause a problem for the Arduino if you press a button for years.

Nope, this was the answer I was looking for. Unless there is maybe a better switch type, than a momentary switch to lift up the LCD and hold it there until it was no longer wanted/needed.

vinceherman:
One of the cool things about hobby servos. You tell it to go and it goes there.
You want it to stay there, then don't tell it to go somewhere else.

This assumes it has enough torque to be able to move it with whatever load you have on it.
If the servo has to work hard to keep its position, it might overheat. I try to design such things so that mechanically the movement of the linkages locks the moving piece into position and the servo motor does not have to bear (as much of) the force to keep it there.

That video shows the LCD screen flipping up. When it is on the way up, the servo has to lift much of the weight of the screen.
But when the screen is in the full upright position, it looks like most of the weight will be on the hinge and the servo will need very little force to hold it there.

Another concern is on the retract side of things. You tell the servo to lower the screen. if the servo moves a little further than is necessary to lower the screen, it might bind, trying to get the screen lower that the physical limits permit. This also could overheat the servo.

In my design, once the lid(LCD) hits 90°, something else will be holding it in place. But the servo will need to get it there, and back down.

The LCD I ordered is very light weight. I have a 1G servo as well as a futaba if the 1G cannot do it.

Thanks for the info, this is what I was looking for!

Capture.PNG

fodelement:
Nope, this was the answer I was looking for. Unless there is maybe a better switch type, than a momentary switch to lift up the LCD and hold it there until it was no longer wanted/needed.

There are other options.

You could use a toggle switch so you don't need to keep your finger on it, and the position of the toggle would indicate whether the screen is up or down.

You could arrange your code so that a momentary button press causes the screen to rise and the next momentary push causes it to descend,

...R