Page 1 of 1

Servo keeps moving

Posted: 28 Mar 2020 10:43
by pieter
All,

Hopefully you can get me out of the following issue. At the moment I want to control a servo (Furaba S3003) and I am able to control it. But when it has arrived its position, it keeps moving every second for around 10 degrees. I am using an external power source.

This is what I tried:
  • All possible PINS (9 - 16)
  • Controlling the servo via an Arduino (which works)
This is the code I am using:

Code: Select all

#include <ZUNO_SERVO.h>

#define SERVO 12

ZUNO_SETUP_CHANNELS(ZUNO_BLINDS(getData, setData));
ZUNO_SETUP_DEBUG_MODE(DEBUG_ON);

ServoController servo(SERVO);
int positionDegrees;
int positionPercentage;

void setup() {
  servo.begin();
  
  Serial.begin(115200);
  
  doServo(90);  
}

void loop() {
  // Managed by ZUno.
}


byte getData() {
  return positionPercentage;
}

void setData(byte data) {
  Serial.print("Percentage: ");
  Serial.println(data);

  positionPercentage = data;
  int value = map(data, 0, 99, 15, 165);
  
  doServo(value);
}

void doServo(int pos) {
  setServo(pos);
}

void setServo(int value) {
  Serial.print("Degrees: ");
  Serial.println(value);
  Serial.println("- - -");
  
  servo.setValue(value);
  positionDegrees = value;
}
Thanks in advance! :)