pxt-ev3/docs/reference/motors/motor/set-reversed.md
Galen Nickel 88c58b4e76 First set of 'motors' topics (#305)
* Start of 'motors' topics

* Draft the 'motor motion' side doc

* Add / update more topics

* Last blast of edits

* Capture some more edits

* Put in movement and steering details
2018-02-06 19:43:50 -08:00

1.1 KiB

set Reversed

Change the direction of rotation for a motor.

motors.largeA.setReversed(true)

You use a positive value (some number greater than 0) to drive you motor in the default direction. If you're using a motor in a way that makes more sense for your program to use a negative speed setting for that direction, you can reverse the speed range.

Paramters

  • reversed: a boolean value that is false if the motor will use a speed value between 0 and 100 to turn in the default direction. If true, the motor uses a speed value between 0 and -100 to turn in the default direction.

Example

Run the motor connected to port A for 2 seconds at a speed of 30. Stop and switch the direciton of rotation. Run the motor at a speed of -30. Watch and see if the motor turns in the same direction as before.

motors.largeA.setSpeed(30)
loops.pause(2000)
motors.largeA.stop()
loops.pause(2000)
motors.largeA.setReversed(true)
motors.largeA.setSpeed(-30)
loops.pause(2000)
motors.largeA.stop()

See also

stop