Servo does not refresh after one write command.

Please help,

I've been working on this program, to control two servos. When I attach the servo's and calibrated them in the setup, everything is working fine. But when the servers are waiting for more than 5000 milliseconds, there is no way to get the servo's into new position. It seems like they don't listen anymore to my arduino due. The pins are connected to 8 and 9 (pwm).

I know there is SoftwareServo lib with the refresh function but i don't want to use this instead of servo.h because i like the timers in it.

Can somebody tell me how to solve this?

Thanks

Are your servo's designed to run from 3.3V control signal?

You haven't posted your code so how can we be sure there isn't a problem with it?

The servo's work just fine at 3.3 volt. The arduino knob sample does well.

This is my code to map value and write it to the servo's.

const int tilt_samples = 5;
int tilt_array[tilt_samples];
int tilt_count = 0;
for(int i=0; i<=tilt_samples; i++){
//delay(5);
pwm_cam_tilt = pulseIn(PWM_PIN_CAM_TILT, HIGH);
//delay(5);
int pwm_cam_tilt_map = map(pwm_cam_tilt, min_value, max_value, 3, 90);
//delay(5);
tilt_array = pwm_cam_tilt_map;
tilt_count = tilt_count + tilt_array*;
_
}_
int tilt_average = tilt_count / tilt_samples;
_
//delay(5);_
tiltServo.write(tilt_average); *

* const int pan_samples = 5;
int pan_array[pan_samples];
int pan_count = 0;
for(int i=0; i<=pan_samples; i++){
pwm_cam_pan = pulseIn(PWM_PIN_CAM_PAN, HIGH);
int pwm_cam_pan_map = map(pwm_cam_pan, max_value, min_value, 0, 160);
pan_array = pwm_cam_pan_map;
pan_count = pan_count + pan_array;
_ }_
int pan_average = pan_count / pan_samples;
_ //delay(5);_
panServo.write(pan_average);*

*so when i change pan or tilt average, the servo's will not react on new value. *

No, post the whole sketch in code tags ( </> button )

I take 5 samples of the pwm input and then take the average of it. Next i want to write it to the servo and the servo does nothing. I try'd other servo's and nothing will work.

  const int tilt_samples = 5;
  int tilt_array[tilt_samples];
  int tilt_count = 0;
  for(int i=0; i<=tilt_samples; i++){
    //delay(5);
    pwm_cam_tilt = pulseIn(PWM_PIN_CAM_TILT, HIGH);
    //delay(5);
    int pwm_cam_tilt_map = map(pwm_cam_tilt, min_value, max_value, 3, 90);
    //delay(5);
    tilt_array = pwm_cam_tilt_map;
    tilt_count = tilt_count + tilt_array;  
  }
  int tilt_average = tilt_count / tilt_samples;
  //delay(5);
  tiltServo.write(tilt_average);               

  
  
  const int pan_samples = 5;
  int pan_array[pan_samples];
  int pan_count = 0;
  for(int i=0; i<=pan_samples; i++){
    pwm_cam_pan = pulseIn(PWM_PIN_CAM_PAN, HIGH);
    int pwm_cam_pan_map = map(pwm_cam_pan, max_value, min_value, 0, 160);
    pan_array = pwm_cam_pan_map;
    pan_count = pan_count + pan_array;  
  }
  int pan_average = pan_count / pan_samples;
  //delay(5);
  panServo.write(pan_average);
for(int i=0; i<=pan_samples; i++)

That's likely to try to put six items into a five item space.

pan_array = pwm_cam_pan_map;This is clearly nonsense.

In fact, you don't need the array at all - you never use the stored values.

It doesn't seem like any values are put in the array anyway.

 tilt_array = pwm_cam_tilt_map;

shouldn't this be?

tilt_array[i] = pwm_cam_tilt_map;

shouldn't this be?

It should, but the forum had already mangled it when the OP cut-and-pasted it from their original.

Of course, as a moderator, I do have to privileges (if such they are) to modify anyone's post, but I figure if they can't be bothered to read the clearly-posted guidelines, I can't be bothered to correct their posts.

Yes it should be

tilt_array[i] = pwm_cam_tilt_map;

to fill the array!

but it's still not refreshing the servo!

Did you fix the other problems?

to fill the array!

Which you don't need

Post your code, this time use code tags.

Dear arduino friends,

Their where no other problems!! I remove the array brackets for debugging the code.

The only question I had was, " why the servos won't refresh while my var tilt_average is changing value".

But lucky me i found the problem. I imported adafruit's lib for controlling neopixels. This lib collides with the servo lib on the arduino due. Strange enough it works fine on the 328P chips. And the programs individually works ok to.
Problem solved.

Thanks for trying to help me

There was also the problem that you were forcing six readings into a space reserved for five.
That never goes well.

That does not answer the original question, does it? By the way. The arduino IDE does not complains about array's out of bounds.

By the way. The arduino IDE does not complains about array's out of bounds.

Why should it? How could it?

Did you fix it?

If you didn't you'll be back at some point complaining your code doesn't work in ways you don't understand.

That does not answer the original question, does it?

The original question was incomplete (it didn't mention the Neopixel), as was the code you posted, yet you expect a complete answer?
Good luck with that attitude.