LiviuM 43 Posted February 14, 2017 Share Posted February 14, 2017 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.