%% Program that should be used to drive the motor
%% your assignment task is to estimate the position that his program produces

close all; clear all; % close all figure windows and clear workspace

% set up connection to brick
COM_CloseNXT('all');  
hNXT=COM_OpenNXT(); 
COM_SetDefaultNXT(hNXT);

% Define motor command for forward movement
forward=NXTMotor('B'); 
forward.Power=20; 
forward.TachoLimit=0; 

backward=NXTMotor('B'); 
backward.Power=-20; 
backward.TachoLimit=0; 

for i=1:100
    forward.SendToNXT();
    tic;
    while toc<1
    end
    
    backward.SendToNXT();
    tic;
    while toc<1
    end
        
end

%%cleaning up
forward.Stop('off');
CloseSensor(SENSOR_1);
COM_CloseNXT(hNXT);

