# Difficulty with servo control using TI MSP430

I'm using an MSP430FR4133 chip to test out a servo (I haven't used or interfaced with servos before). I believe I've attached the servo wires to the correct pins, but when I run the program to turn it 90 degrees and then back to 0, all I hear is clicking inside of the servo. Here's my code and the pin diagram:

The servos operate on 5-6V so I connected the servo ground wire to GND (Pin 1), the servo power wire to 5V (Pin 1) and the servo control wire to PWM (Pin 19).

And here's my code:

#include <Servo.h>

Servo servo;

int pos = 0;
const int buttonPin = PUSH2;

void setup() {
pinMode(buttonPin, INPUT_PULLUP);
servo.attach(11);
}

void loop() {

if (buttonState == LOW) {
servo.write(90);
}
}


Any and all help would be appreciated.

• There could be many things wrong here, but one that immediately jumps out is that you generally should not draw power for a hobby servo or any other motor through an MCU board. The MCU should provide signal; you need to provide dedicated paths for power, and of course have a common ground between signal and power. – Chris Stratton Oct 29 '18 at 0:43
• What Chris said about the power supply. I was half expecting you to say you told it to move and the processor locked up! I'm not familiar with the code base you're using -- you may want to double-check the documentation and make sure that you call servo.write with an argument in degrees -- it could easily be an argument in tenths or 1/100ths of degrees. If it is 1/100ths of degrees, then when you told the servo to move 90/100ths of a degree it may very well make a 'tick' but no apparent motion. – TimWescott Oct 29 '18 at 1:00
• "but when I run the program to turn it [to] 90 degrees and then back to 0" - where does your code do that? – Bruce Abbott Oct 29 '18 at 1:57
• You mentioned that you have attached the control wire to 'pin 19'..but the code has 'servo.attach(11)'. Thats the thing I noticed as a arduino user. Try editing that as well. – Giga-Byte Oct 29 '18 at 3:12
• I'm not familiar with the library you're using but are you sure 90 is 90 degrees? A lot of libraries interpret 1500 as 0 degrees and 1000 as -90 degrees and 2000 as 90 degrees (or at least servo_min_travel and servo_max_travel which may be 45 degrees or 90 degrees or 180 degrees or any other value depending on servo) – slebetman Oct 29 '18 at 5:21