Letting 16 servo's move up and down in wave like form

Hi all,

Am trying to use 16 servo’s divided over 2 boards to move up and down in a sinus wave form. Am not sure what the best way to code this. Any ideas ?

thx in advance

void patroon(){
  for (servo = 0; servo < 16; servo++) {
    Nservo = servo / 2;
    boardNumber = servo / 8;
    pwm[boardNumber].setPWM(Nservo, 0, servomin);


 }

}

https://www.adafruit.com/product/815

See second small image. Leo..

dont understand what you mean with the image

I would definitely use a driver like the adafruit product that Wawa linked to.

I am nut sure I understand the movement you are describing. Do you want each one to move slightly out of phase, so that it looks like a wave rolling by?

Then I would write code to make one sweep the way you want. This would likely be code similar to the sweep tutorial but with the adafruit library rather than the Servo.h library. Then I would expand it to include multiple servos, each one slightly out of phase.

Feel free to expand on the movement you want to produce.

yes got two of these boards :slight_smile:

I was thinking of something like this …

void wavetest(){
  for (uint16_t movement = servomin; movement < servomax; movement++) {
    for (servo = 0; servo < 16; servo++) {
    Nservo = servo / 2;
    boardNumber = servo / 8;
    pwm[boardnumber].setPWM(Nservo, 0, movement);
    delay(delayvalue); // start delay to create wave form
    }
}
  for (uint16_t movement = servomin; movement > servomax; movement--) {
    for (servo = 0; servo < 16; servo++) {
    Nservo = servo / 2;
    boardNumber = servo / 8;
    delayvalue = 0; // reset delay
    pwm[boardnumber].setPWM(Nservo, 0, movement);
    
     }
  }
}

Awesome. How does it work?

Oh, in the future, it is helpful to see the entire sketch. That lets us see the names of any libraries you use and hoe variables are declared.

not yet tested ...am at work ^^

Looks like the discussion is continuing here: http://forum.arduino.cc/index.php?topic=549800