Controlling Spektrum Linear Servos with Arduino Uno

Hey all! I’m very new to Arduino, and have encountered an issue while writing a program. I need to control the Spektrum micro linear servos with an Arduino
(It’s an Uno, although I suspect that is insignificant here). Find the servos here for reference: https://spektrumrc.com/Products/Default.aspx?ProdID=SPMSA2030LO
I am trying to achieve a command like ‘move 3 mm then stop’. Or, more optimally ‘move based on the output of a sensor’. But the idea is that I need to get the linear servos to actuate by way of Arduino control. I have tried to code for them using the normal Servo library. Trying with writeMicroseconds and .write(degrees). Also tried defining (pin, min, max). None of these functions controls the linear servos. I tried with the signal wire attached to pin 9 (PWM pin) and to the A0 - A5 pins. No response from servo (although it is powered on from 5V power source). I have also tried powering from 3.7V. No change; no signal response. I then tried to change the PWM frequency using the pwm.write function from the PWM.h library. I tried 50 Hz because that is the normal frequency for hobby servos. No response. Tried with various other frequencies; no response. I need need need to control these servos. Any ideas? Thanks!

AeroCraft

Hello @AeroCraft and welcome to the RobotShop forum,

Could you share a picture of your setup so we can see the connections?

Also, keep this in mind:

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note that servos draw considerable power, so if you need to drive more than one or two, you’ll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together.

Thanks for your reply. See photo:

The servo and LiPo share a common ground. That ground is connected to GND on the Arduino. Approx. 3.7V comes from the LiPo (1S). The signal wire from the servo is connected to pin 9 on the Arduino: a PWM pin. The servo makes little jittering noises, so it is alive, just unresponsive to my code. Code is here; very simple:

#include <VarSpeedServo.h>

int pos;
int wait = 500;
String msg = “Please specify servo pulse width in microseconds.”;

VarSpeedServo servo;

void setup() {
Serial.begin (9600);
servo.attach (9, 1100, 1900);
}

void loop() {
Serial.println (msg);
while (Serial.available()==0){}
pos = Serial.parseInt();
servo.writeMicroseconds (pos);
delay(wait);
}

Thanks for addressing my query.

The servo and LiPo share a common ground. That ground is connected to GND on the Arduino. Approx. 3.7V comes from the LiPo (1S). The signal wire from the servo is connected to pin 9 on the Arduino: a PWM pin.

Sounds good! Everything seems to be in order.

Have you tried using a different PWM pin?

You are right, the code is very simple but if it isn’t working you could try something even more simple. Try using the sweep example

Is speed important in your project? Have you tried using the regular Servo library instead of VarSpeedServo?