I have a very peculiar problem getting a servo to work with the Wixel. The test program I am using for this is shown below. In running this program, the servo by itself never moves. However, when I touch any kind of ground (including my hand) to the jumper wire terminals powering the servo, it begins to move, just not in the way it should. In endlessly turns one direction and at the same speed, no matter how I change the program. I have tried modifying the servo targets, speed, and even changing pins, but nothing changes anything. Here is the code I am working with. If someone could help me get the servo working properly, that would be great.
#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
#include <servo.h>
uint8 CODE pins[] = {11}; // Use P1_1 for servos.
void updateLeds()
{
usbShowStatusWithGreenLed();
}
void myServosInit()
{
servosStart((uint8 XDATA *)pins, sizeof(pins));
servoSetSpeed(0, 10);
}
void updateServos()
{
if (getMs() >> 11 & 1)
{
// For 2048 ms, the code in this block will be called.
// Then for the next 2048 ms, the code in the "else" block will be called.
// The pattern repeats every 4096 ms.
servoSetTarget(0, 1000);
LED_YELLOW(0);
}
else
{
servoSetTarget(0, 1500);
LED_YELLOW(1);
}
}
void main()
{
systemInit();
usbInit();
myServosInit();
while(1)
{
updateLeds();
boardService();
usbComService();
updateServos();
}
}
EDIT: I forgot to mention, the servo I am using is Pololu’s own “Sub-Micro Servo 3.7g (Generic)”.