Hello all,
I’ve been trying for the last little while to create an arm that I plan on playing tic-tac-toe with, and I’ve run into a snag in the movement function. I have each “square” on the board as a structure with values for the servo positions and whether or not it has an ‘X’ or ‘O’. As you can see, it’s laid out like this:
typedef struct{
int basePos;
int armPos;
int wristPos;
byte knot;
byte cross;
}
cell;
cell ticTac[2][2];//goes ROW -> COLCUMN
And the structure variables are defined in setup like this:
ticTac[0][0].basePos = 120;
ticTac[0][0].armPos = 124;
ticTac[0][0].wristPos = 47;
ticTac[0][1].basePos = 105;
ticTac[0][1].armPos = 132;
ticTac[0][1].wristPos = 71;
ticTac[0][2].basePos = 95;
ticTac[0][2].armPos = 148;
ticTac[0][2].wristPos = 105;
ticTac[1][0].basePos = 100;
ticTac[1][0].armPos = 116;
ticTac[1][0].wristPos = 36;
ticTac[1][1].basePos = 85;
ticTac[1][1].armPos = 132;
ticTac[1][1].wristPos = 67;
ticTac[1][2].basePos = 85;
ticTac[1][2].armPos = 142;
ticTac[1][2].wristPos = 94;
ticTac[2][0].basePos = 65;
ticTac[2][0].armPos = 126;
ticTac[2][0].wristPos = 47;
ticTac[2][1].basePos = 65;
ticTac[2][1].armPos = 131;
ticTac[2][1].wristPos = 68;
ticTac[2][2].basePos = 65;
ticTac[2][2].armPos = 148;
ticTac[2][2].wristPos = 105;
for(i = 0; i <= 2; i++){
for(j = 0; j <= 2; j++){
ticTac[j][i].knot = 0;
ticTac[j][i].cross = 0;
}
}
Whenever I try writing to any of the servos (attached to the correct pins and wired properly of course) the servos do not move. I would try writing the “write” method like this:
base.write(ticTac[0][0].basePos);
arm.write(ticTac[0][0].armPos);
wrist.write(ticTac[0][0].wristPos);
Any suggestions? Any help at all would be greatly appreciated.
PS: A copy of this code is available right here: http://pastebin.com/tEcMyCJG