function data = writeMem(H,addr,data)

globalVar;

sendServo(H,WRITE_MEM,addr,data,0,0,0,0);
[command,return1] = readServo(H);

if(~(command == WRITE_MEM && return1 == 0))
    disp('OPERATION FAILED: Write Memory');
end