Jump to content
Sign in to follow this  
LiviuM

TivaC TM4C1294 - Servo library broken?

Recommended Posts

Hello,

 

these days I was trying to use an array of servos, something like:

#include <Servo.h>

#define IOS_NR 5

byte myIos[IOS_NR] = {1,2,3,4,5};

Servo myServos[IOS_NR];

boolean bServoOut[] = {true false, false, true, false};

void setup(){
   for(i=0; i < IOS_NR; i++){
      if(bServoOut[i]){
         myServos[i].atatch(myIos[i]);
      }
   }
}

void loop(){
   
// do some things

      if(bServoOut[k]){
         myServos[k].write(servoValue);
      }

// do other things
}

but the servos behaved totally other than expected. Digging through the Servo library, I've found some (in my opinion) wrong used indexes and (again, in my opinion) fixed them.

After the fix my two servos behave as expected.

 

I'm attaching the changed files (actually only the .cpp file is changed), maybe someone can test them thoroughly than I, or even use them.

 

Best regards,

Liviu

 

PS I've renamed the files after the project I'm using them in.

RNServo.zip

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...