This is one of my very first NXT Mindstorm programs - it is simple, yet effective. This program first resets the rotation sensor to 0, then starts a loop taking the position on a single joystick axis in degrees, and sends the value to the math block. So, for this example lets say this is the program for left and right. The joystick is being pushed 22 degrees to the right. The value would be sent to the first math block which works out what 1% would be by dividing the degree value by 100 which would be 0.22. This result is then sent to the second math block, which is preset by me to times the 1% by 15, giving me 3.3. The result is then sent to the LEGO power functions controller which has a speed scale of 0-7, "0" being stop and "7" being full speed. This repeats until the loop is stopped by the joystick returning to 0 degrees.
![]() This program is a little bit more complicated as two motors are controlled and four math blocks are used. The first part starts and runs just like before but this time a second motor is used to stop counter rotation on the wrist or grab. The result of 3.3 is sent to the third math block, which times the value by 2 in this example giving 6.6. This result is then fed to the second input on the fourth math block and the raw (unchanged) value from the last math block is also sent to the first input value. In simple terms this is now a sum of 3.3 minus 6.6 giving -3.3 this is now sent to the LEGO power functions controller. Motor A is rotating 3.3 (just under half speed clockwise) and Motor B is rotating -3.3 ( just under half speed counter clockwise). |

