I am trying to control my DSS-m15S servo motor, but all my attempts failed, even though I edited the Pulse range: - 500-2500 us - as datasheet said and put it in the code:
myservo.attach(9,500,2500);
it needs to be mentioned that I could control it (partially) throw using For loop like this:
for (angle = 0; angle <= 180; angle++) {
myservo.write(angle);
delay(10);
}
// And back from 180 to 0 degrees:
for (angle = 180; angle >= 0; angle--) {
myservo.write(angle);
delay(10);
}
partially: means the motor starts moving After a stop and giving a ticking sound with no movement, it only starts moving from 0 to 270 even it's not configured to do that.
I tried to increase the angle from {angle++} to {angles = angle +10} but it stopped moving, with the ticking sounds only.
full code:
#include <Servo.h>
// Create a new servo object:
Servo myservo;
// Define the servo pin:
#define servoPin 9
// Create a variable to store the servo position:
int angle = 0;
uint16_t val;
void setup() {
// Attach the Servo variable to a pin:
myservo.attach(9,500,2500);
Serial.begin(9600);//Set Baud Rate to 9600 bps
}
void feedback( )
{
val=analogRead(A0);//Connect Analog pin to A0
dat = (double) val * 0.47-33.4;
Serial.print("Position:"); //Display the position on Serial monitor
Serial.print(dat);
Serial.println("Degree");
delay(10);
}
void loop() {
// Tell the servo to go to a particular angle:
// Sweep from 0 to 180 degrees:
for (angle = 0; angle <= 180; angle++) {
myservo.write(angle);
delay(20);
}
// And back from 180 to 0 degrees:
for (angle = 180; angle >= 0; angle--) {
myservo.write(angle);
delay(20);
}
}
Please Help!