Vixen with servo's

Hi all, hopefully I’m placing this in the right place… (and first of all sorry if my English is not that good… :slight_smile: )

I’ve been making an animatronic that I wanted to control via the Vixen 3.0 software. With the help of this great instructable (https://www.instructables.com/id/Talking-Pumpkins/) I managed to make things work as prescribed, so with 3 servo’s attached (it didn’t matter if I used the normal or the micro servos). It all worked as it should, but here’s the problem:

When I want to add more servo’s than the 3 as seen in the Instructable and I connect them to my Arduino Mega all the servo’s just go crazy and nothing works like it should. I’ve tried to contact the creator of the script as placed on the Instructable but there is no response… So I hope someone here can help me.

The hardware I use:

  • Arduino Mega
  • 4 servo’s
  • 4 micro servo’s
  • 5v servo powerboard

The way I wired everything:

  • signal cables of the servos to pin 3, 5, 6, 9, 10, 11, 12, 13
  • 5v and GND of the servos to the powerboard

The script as seen on the instructable:

/*
  This code runs vixen through the arduino, usining pins 3, 5, and 6 with
  3 seperate servos; pins 9, 10, and 11 are used for 3 LED circuits with PWM;
  pins 12, 13 are extra digital pins. 
*/

#include <Servo.h>
Servo Pumpkin1;
Servo Pumpkin2;
Servo Pumpkin3;
int pos = 0;

int Chan1 = 3;     //PWM-Servo 1
int Chan2 = 5;     //PWM-Servo 2
int Chan3 = 6;     //PWM-Servo 3
int Chan4 = 9;     //PWM-Light 1
int Chan5 = 10;    //PWM-Light 2
int Chan6 = 11;    //PWM-Light 3
int Chan7 = 12;     //extra
int Chan8 = 13;    //extra



int i = 0;     // Loop counter
int incomingByte[8];   // array to store the 25 values from the serial port
int val1;
int val2;
int val3;

//setup the pins/ inputs & outputs
void setup()
{
  Serial.begin(9600);   // set up Serial at 9600 bps

  pinMode(Chan1, OUTPUT);
  Pumpkin1.attach(3);
  pinMode(Chan2, OUTPUT);
  Pumpkin2.attach(5);
  pinMode(Chan3, OUTPUT);
  Pumpkin3.attach(6);
  pinMode(Chan4, OUTPUT);
  pinMode(Chan5, OUTPUT);
  pinMode(Chan6, OUTPUT);  
  pinMode(Chan7, OUTPUT);
  pinMode(Chan8, OUTPUT);
}

void loop()
{  // 8 channels are coming in to the Arduino
   if (Serial.available() >= 8) {
    // read the oldest byte in the serial buffer:
    for (int i=0; i<9; i++) {
      // read each byte
      incomingByte[i] = Serial.read();
    }
    //Pumpkin1
    val1 = incomingByte[0];                  
    val1 = map(val1, 0, 255, 0, 45);    //Change the last number according to how far you want the pumpkin to open.
    Pumpkin1.write(val1);                   
    delay(15);                            
    //Pumpkin2
    val2 = incomingByte[1];
    val2 = map(val2, 0, 255, 0, 45);    //Change the last number according to how far you want the pumpkin to open.
    Pumpkin2.write(val2);
    delay(15);
    //Pumpkin3
    val3 = incomingByte[2];
    val3 = map(val3, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    Pumpkin3.write(val3);
    delay(15);

    analogWrite(Chan4, incomingByte[3]);      //Light 1
    analogWrite(Chan5, incomingByte[4]);      //Light 2
    analogWrite(Chan6, incomingByte[5]);      //Light 3
    digitalWrite(Chan7, incomingByte[6]);       //Extras
    digitalWrite(Chan8, incomingByte[7]);       //Extras
   }
}

The code as I edited it:

/*
  This code runs vixen through the arduino, usining pins 3, 5, and 6 with
  3 seperate servos; pins 9, 10, and 11 are used for 3 LED circuits with PWM;
  pins 12, 13 are extra digital pins. 
*/

#include <Servo.h>
Servo knipper1;
Servo knipper2;
Servo ogen1;
Servo ogen2;
Servo hoofd1;
Servo hoofd2;
Servo base;
Servo mond;
int pos = 0;

int Chan1 = 3;     //knipper1
int Chan2 = 5;     //knipper2
int Chan3 = 6;     //ogen1
int Chan4 = 9;     //ogen2
int Chan5 = 10;    //hoofd1
int Chan6 = 11;    //hoofd2
int Chan7 = 12;     //base
int Chan8 = 13;    //mond



int i = 0;     // Loop counter
int incomingByte[10];   // array to store the 25 values from the serial port
int val1;
int val2;
int val3;
int val4;
int val5;
int val6;
int val7;
int val8;

//setup the pins/ inputs & outputs
void setup()
{
  Serial.begin(9600);   // set up Serial at 9600 bps

  pinMode(Chan1, OUTPUT);
  knipper1.attach(3);
  pinMode(Chan2, OUTPUT);
  knipper2.attach(5);
  pinMode(Chan3, OUTPUT);
  ogen1.attach(6);
  pinMode(Chan4, OUTPUT);
  ogen2.attach(9);
  pinMode(Chan5, OUTPUT);
  hoofd1.attach(10);
  pinMode(Chan6, OUTPUT);
  hoofd2.attach(11);  
  pinMode(Chan7, OUTPUT);
  base.attach(12);
  pinMode(Chan8, OUTPUT);
  mond.attach(13);
}

void loop()
{  // 8 channels are coming in to the Arduino
   if (Serial.available() >= 10) {
    // read the oldest byte in the serial buffer:
    for (int i=0; i<10; i++) {
      // read each byte
      incomingByte[i] = Serial.read();
    }
    //knipper1
    val1 = incomingByte[0];                  
    val1 = map(val1, 0, 255, 0, 45);    //Change the last number according to how far you want the pumpkin to open.
    knipper1.write(val1);                   
    delay(15);                            
    //knipper2
    val2 = incomingByte[1];
    val2 = map(val2, 0, 255, 0, 45);    //Change the last number according to how far you want the pumpkin to open.
    knipper2.write(val2);
    delay(15);
    //ogen1
    val3 = incomingByte[2];
    val3 = map(val3, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    ogen1.write(val3);
    delay(15);
        //ogen2
    val4 = incomingByte[3];
    val4 = map(val4, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    ogen2.write(val4);
    delay(15);
        //hoofd1
    val5 = incomingByte[4];
    val5 = map(val5, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    hoofd1.write(val5);
    delay(15);
        //hoofd2
    val6 = incomingByte[5];
    val6 = map(val6, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    hoofd2.write(val6);
    delay(15);
        //base
    val7 = incomingByte[6];
    val7 = map(val7, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    base.write(val7);
    delay(15);
        //ogen1
    val8 = incomingByte[7];
    val8 = map(val8, 0, 255, 0, 45);     //Change the last number according to how far you want the pumpkin to open.
    mond.write(val8);
    delay(15);

   }
}

Many thanks for the help in advance!

Sorry to bother! I solved it myself! The problem was the baudrate! When chaning it to 115000 it worked!