Feedback loop changes input [Arduino]

hello everyone,

I want to move a servomotor according to the distance I get from this distance sensor by using an Arduino Uno.
But as soon as I activate the feedback loop, the distance sensor’s output gets random.
Controlled by an I/O-Box the servo works fine, but with the feedback loop it trembles according to the distorted sensor output.

Connecting a Battery to the Arduino also doesn’t help.

If it’s any help, I have attached an arduino sketch that works with the exact same setup. (But I need the vvvv patch for easier development)

I’m glad for any help.

working arduino sketch:

- include "Maxbotix.h"
- include <Servo.h> 
Servo myservo;

int pos = 0; 
int old = 0; 

Maxbotix rangeSensorAD(A0, Maxbotix::AN, Maxbotix::LV);

void setup()

void loop()

  // AD
  int range = rangeSensorAD.getRange();
  Serial.print("AD: ");                     
  Serial.print("cm      ");           
  int mr5 = map(range,15,300,0,56);   
  int mr = map(mr5,0,56,170,80);      
  if(mr != old) {        
    old = mr;            

just a guess u need to use frame difference with frame delay

I use a frame delay, so that shouldn’t be the problem.

But i just found out the problem in the sensor value also occurs if i don’t activate the loop, but keep moving the servo by using the fader in the patch. So it might be something about the arduino data connection.

hi a.b. :)

hm. you could try to use a Damper (Animation) or LinearFilter (Animation) with as little time values as possible.

what is that little noise in the smooth, right side, part of the curve? as that something moving in the sensor beam?

what could also help is to power the servo from a different, stable power source, as it might draw too much current and therefor interfere the AD converter on the Arduino. Make sure to connect the ground wire from this external power supply to the Arduino too; otherwise the signal transmission to the servo might not work.

Lastly, note, that in the standalone sketch there is a sampling rate / loop of 200 ms. You can adjust this value for Firmata too using the Inspektor on the Arduino node; try setting the sampling rate to 200 or less and keep us posted, if it helps.