[LIB] ShiftOut + Servos

I have to say, its nothing too hard do what i did, but in actions is pretty cool :smiley:
I have taken the SoftwareServo lib ( Arduino Playground - HomePage ) edited a bit and it can control servos attached on a Shift register (http://arduino.cc/en/Tutorial/ShiftOut )

Tested on arduino IDE 0022

Video:

Lib attached on the topic.
This is an example:

#include <ShiftOutServo.h> //Just including

#define latchPin  A0
#define clockPin  A2
#define dataPin  A1
//I am using analog pins vbut you can also use digitals...

byte pins[] = {latchPin,clockPin,dataPin};
bool originalData[] = {0,0,0,0,0,0,0,0}; //The [0] and [1] is for servos

ShiftOutServo servo1;
ShiftOutServo servo2;
void setup(){
        pinMode(latchPin, OUTPUT);
        pinMode(clockPin, OUTPUT);
        pinMode(dataPin, OUTPUT);
        servo1.attach(0);
        servo2.attach(1);
}

int the_angle = 0;
long int timett;
int adding = 2;
int bgn =  2;
void loop()
{
  servo1.write(the_angle);
  servo2.write(180-the_angle);
  //Shifting some leds...
  originalData[bgn] = 0;
  bgn++;
  if (bgn == 8){
      originalData[7] = 0;
      bgn = 2;
  }
  originalData[bgn] = 1;

  //Its nice do it to reduce noise...
  timett = millis()+10;
  while(timett >= millis()){
    ShiftOutServo::refresh(pins,originalData);
  }

  the_angle= the_angle+adding;
  if (the_angle >= 180 || the_angle <= 0 ) adding = adding*(-1);
  delay(10);

}

ShiftOutServo.rar (3.8 KB)