Motor Speed via Motor Rotation

Content
Drive the speed of one motor by the amount of rotation of a second.
Code

This (version 1) directly inputs the value of the B motor into the power of the A motor.  The "reset rotation" at the beginning of the code, before the start of the While Loop, just ensures when the program starts it is set at zero. 

Code
In the prior example (version 1), it is very easy to "exceed" the range of motor powers.  So this code "divides the rotation by 10" before inputting it into the drive motor function.  In this way, this version (version 2) will read the motor from -1000 degrees to 1000 degrees (over 2.5 full turns in either direction).
Attachments

Leave a Reply

Your email address will not be published. Required fields are marked *