Hi all, I have a servo controlled via 4 pushbuttons for positions (+ led position indicator).
Everything seems to work but the servo simply won't turn to the various position as supposed to.
It does indeed move, the 0 point seems to be at 92 degree and it's fine but I supposed it's limited.
I'm using an HENGE MD5924D.
My code
#include <Servo.h>
Servo myservo;
int p1 = 2;
int p2 = 3;
int p3 = 4;
int p4 = 5;
int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 8;
void setup() {
myservo.attach(9);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite (led1, HIGH);
digitalWrite (led2, LOW);
digitalWrite (led3, LOW);
digitalWrite (led4, LOW);
}
void loop() {
int p1 = digitalRead(2);
int p2 = digitalRead(3);
int p3 = digitalRead(4);
int p4 = digitalRead(5);
if (p1 == HIGH) {
digitalWrite (led1, HIGH);
digitalWrite (led2, LOW);
digitalWrite (led3, LOW);
digitalWrite (led4, LOW);
myservo.write(92);
delay(1000); }
if (p2 == HIGH) {
digitalWrite (led1, LOW);
digitalWrite (led2, HIGH);
digitalWrite (led3, LOW);
digitalWrite (led4, LOW);
myservo.write(180);
delay(1000); }
if (p3 == HIGH) {
digitalWrite (led1, LOW);
digitalWrite (led2, LOW);
digitalWrite (led3, HIGH);
digitalWrite (led4, LOW);
myservo.write(0);
delay(1000); }
if (p4 == HIGH) {
digitalWrite (led1, LOW);
digitalWrite (led2, LOW);
digitalWrite (led3, LOW);
digitalWrite (led4, HIGH);
myservo.write(120);
delay(1000); }
}
I've read about continuos servo, winch servo...but I don't know if it's me doing it wrong or simply I need to replace that servo.
Thank you
EDIT: dss-m15s should be good in this case? it's a 270° servo and 270° is the max angle that my project need