Table of Contents

Drive

The Drive function commands the NXT brick to drive one or more of it's motors with a given power and number of rotations.

The motors parameter can be a single motor, for example just “A” or a combination of motors such as “ABC”.

Power is given as a percentage value and negative values make the motor reverse.

If the number of rotations is set to zero, then the motor will continue until the Stop function is called.

nxt.Drive( motors, power, rotations );

Example - Drive forward 3 rotations

function OnStart()
{
  nxt = app.CreateNxt();
  app.SetMenu( "Connect,Drive" );
}
 
function OnMenu( name )
{
  if( name=="Connect" )
    nxt.ShowDevices();
  else if( name=="Drive" )
    nxt.Drive( "BC", 80, 3 );
}