Servo keeps moving

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
pieter
Posts: 1
Joined: 28 Mar 2020 10:28

Servo keeps moving

Post 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! :)
Post Reply