Adafruit 16 channel PWM Servo Shield

Hi,
I need help with Adafruit 16PWM shield.
I connected 6 Analog Feedback Servos to 16PWM Shield
and I would like to record Servos movements an replay them back.
Any help is welcomed.
I used the following code:

// Example code for recording and playing back servo motion with a 
// analog feedback servo
// http://www.adafruit.com/products/1404


#include <Servo.h>
#include <EEPROM.h>

#define CALIB_MAX 512
#define CALIB_MIN 100
#define SAMPLE_DELAY 25 // in ms, 50ms seems good

uint8_t recordButtonPin = 12;
uint8_t playButtonPin = 7;
uint8_t servoPin = 9;
uint8_t feedbackPin = A0;
uint8_t ledPin = 13;

Servo myServo;  
  
void setup() {
  Serial.begin(9600);
  pinMode(recordButtonPin, INPUT);
  digitalWrite(recordButtonPin, HIGH);
  pinMode(playButtonPin, INPUT);
  digitalWrite(playButtonPin, HIGH);
  pinMode(ledPin, OUTPUT);
  
  Serial.println("Servo RecordPlay");
}

void loop() {
 if (! digitalRead(recordButtonPin)) {
   delay(10);
   // wait for released
   while (! digitalRead(recordButtonPin));
   delay(20);
   // OK released!
   recordServo(servoPin, feedbackPin, recordButtonPin);
 }
 
  if (! digitalRead(playButtonPin)) {
   delay(10);
   // wait for released
   while (! digitalRead(playButtonPin));
   delay(20);
   // OK released!
   playServo(servoPin, playButtonPin);
 }
}

void playServo(uint8_t servoPin, uint8_t buttonPin) {
  uint16_t addr = 0;
  Serial.println("Playing");


  myServo.attach(servoPin);
  while (digitalRead(buttonPin)) {    
    uint8_t x = EEPROM.read(addr);
    Serial.print("Read EE: "); Serial.print(x);
    if (x == 255) break;
    // map to 0-180 degrees
    x = map(x, 0, 254, 0, 180);
    Serial.print(" -> "); Serial.println(x);
    myServo.write(x);
    delay(SAMPLE_DELAY);
    addr++;
    if (addr == 512) break;
  }
  Serial.println("Done");
  myServo.detach();
  delay(250);  
}

void recordServo(uint8_t servoPin, uint8_t analogPin, uint8_t buttonPin) {
  uint16_t addr = 0;
  
  Serial.println("Recording");
  digitalWrite(ledPin, HIGH);
  


  
  pinMode(analogPin, INPUT); 
  while (digitalRead(buttonPin)) {
     uint16_t a = analogRead(analogPin);
     
     Serial.print("Read analog: "); Serial.print(a);
     if (a < CALIB_MIN) a = CALIB_MIN;
     if (a > CALIB_MAX) a = CALIB_MAX;
     a = map(a, CALIB_MIN, CALIB_MAX, 0, 254);
     Serial.print(" -> "); Serial.println(a);
     EEPROM.write(addr, a);
     addr++;
     if (addr == 512) break;
     delay(SAMPLE_DELAY);
  }
  if (addr != 512) EEPROM.write(addr, 255);

  digitalWrite(ledPin, LOW);

  Serial.println("Done");
  delay(250);
}

Well that only records one analog channel and you said you had 6. Writing EEPROM is slow, you do know this? Calling delay isn't a great idea - if you want accurate sample timing you'll need to schedule samples, not delay between them.

And I don't see how you can record when the servos are active, they will simply hold position? Or are these special servos?

yes they are special Analog Feedback Servos 1213
I’ struggling wit PWM 16.
I would be happy at this stage with only one servo.

Shake the EEPROM...

But what adafruit PWM shield are you using? I have one that has the I2C interface. So you need to control it by, you guessed it, I2C. I made a small subroutine to control my PWM shield:

void sendWire(int Addr, int Data)
{
    long value = map(Data, 0x00, 0xFF, 0x0180, 0x02E7);
    Wire.beginTransmission(Driver);
    Wire.write(0x06 + (Addr*4));
    Wire.write(0x01); 
    Wire.write(0x00); 
    Wire.write(lowByte(value));
    Wire.write(highByte(value));
    Wire.endTransmission(); 
}

where Addr is the PWM channel address, and Data is the PWM value from 0 to 255. I added the map() function because the motors I used have a specific range of PWM to operate with (Linear motors from some weird company...)

EDIT: I have this one: https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield

EDIT 2: I forgot, you need to set the PWM shield before using it. I have used:

  setWire(0x00, 0x11);
  setWire(0xFE, 0x47);    //0x3F worked-ish
  setWire(0x00, 0x20);

void setWire(int Addr, int Data)
{
  Wire.beginTransmission(Driver);
  Wire.write(Addr);
  Wire.write(Data);
  Wire.endTransmission();
}

But check the datasheet for your own parameters!

yes I have Adafruit 16-channel PWM/Servo Shield over 12C

novio8: yes I have Adafruit 16-channel PWM/Servo Shield over 12C

But you haven't got any I2C commands in your code, or the adafruit PWM shield library... I'd say, start there?

ok
thanx

Just to be sure, the library can be downloaded here: https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library

And there are also some examples to follow.