I have simplified the program a lot and I have managed to pass the movements to the SD:
#include <ax12.h> //Incluir la librería ArbotiX DYNAMIXEL
int SERVO_ID[] = {1, 2, 3, 4}; //números ID de los motores que se están utilizando
const int servo_count = sizeof(SERVO_ID) / sizeof(*SERVO_ID);
int m = 200; //columnas -> cantidad de posiciones guardadas por cada movimiento
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
dxlInit(1000000); //start dynamixel library at 1mbps to communicate with the servos
Serial.begin(9600); //start serial at 9600 for reporting data.
for (int i = 0; i < servo_count; ++i)
{
Relax(SERVO_ID[i]);
Serial.print(F("ID: "));
Serial.println(SERVO_ID[i]);
}
Serial.print("Starting SD ...");
if (!SD.begin(4)) {
Serial.println("It failed to initialize");
return;
}
Serial.println("successful initialization");
delay(1000);
}
void loop() {
while (1) {
int positionn[servo_count][m]; //Matrix of movements
for (int i = 0; i < m; i++) // structure to create columns
{
for (int j = 0; j < servo_count; j++) // structure to create columns
{
positionn[j][i] = dxlGetPosition(SERVO_ID[j]); //read and save the actual position
}
delay(10);
for (int j = 0; j < servo_count; j++) // structure to create columns
{
Serial.print(positionn[j][i]); //Display the vector
Serial.print(F(", "));
String dataString = "";
myFile = SD.open("Prueba.txt", FILE_WRITE);
if (myFile) {
myFile.print(positionn[j][i]);
myFile.print(F(", "));
myFile.close();
}
else {
Serial.println("Error opening the file");
}
}
}
Serial.println(F("END!"));
}
}
but, now, I want to integrate this part of the program in which I have taught you in the previous post.