SoftwareServo problem

hi i have a problem with my project , i have to use both servo and music (simple SD player) so i must use the softwareServo library for avoiding conflicts between libraries . i’m trying to make servos move with the new library but the first servo works well while the second fluctuate between positions and(after a few of flucttuations) reaches a position that is near the position sended but is not the same. what is wrong?

i have to use the refresh() method every 20ms for make servos moving like the stock library;

there is the setup , the servo “Sportello” work but “Braccio” fluctates

#include <SoftwareServo.h>




#include <TrueRandom.h>




#include <sd_l0.h>
#include <sd_l1.h>
#include <sd_l2.h>
#include <SimpleSDAudio.h>
#include <SimpleSDAudioDefs.h>*/
//130°

int pinSportello=3;
int pinBraccio=6;
int rele=7;
int interruttore=2;

const int apribraccio=0;
const int chiudibraccio=110;
const int aprisportello=0;
const int chiudisportello=130;



SoftwareServo Sportello,Braccio;
void setup() {
  // put your setup code here, to run once
  int i;	
pinMode(interruttore, INPUT ); 
  pinMode(rele,OUTPUT);
  digitalWrite(rele,HIGH);
Sportello.attach(pinSportello);
 Braccio.attach(pinBraccio);
// [b]THIS WORKS PERFECTLY[/b] 
  Sportello.write(aprisportello);
  for(i=0;i<40;i++)
  {
   Sportello.refresh();
     delay(20);
   
   
  }  
// [b]THE PROBLEM IS HERE[/b]
  Braccio.write(110);
  for(i=0;i<40;i++)
  {
Braccio.refresh();
    delay(20);
    
  }  
  


  Sportello.write(chiudisportello);
  delay(300);
  Serial.begin(9600);
//SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER);



}

please help me =( =(

I'm not familiar with the sofware servo library.

If you cut out the SD Card stuff will the servos work with the regular servo library?
Servos should have a separate power supply and if you are powering yours from the Arduino 5v pin that can cause all sorts of strange behaviour when the servos cause the voltage to dip below 5v.

There is a ServoTimer2 library that may be worth trying.

...R

i can't use standard servo library for the sd conflicts :frowning: i'm using the same library you linked

EDIT found the solution , the speaker drains too much power from the board and make the second servo crazy

thethrasher1:
i can’t use standard servo library for the sd conflicts :frowning: i’m using the same library you linked

EDIT found the solution , the speaker drains too much power from the board and make the second servo crazy

Glad you found the solution.

You are not using the library that I referred to. The one I referred to uses #include <ServoTimer2.h> and it is controlled just like the regular servo library without any need for refresh() commands.

…R