Question

Can you control a Lego Mindstorm NXT 2.0 robot over bluetooth from a computer? For example using the arrow keys on the keyboard to make the robot move wirelessly (over bluetooth or something else)?

Was it helpful?

Solution

Yes absolutely. I like to use Microsoft Robotics Studio and with a simple program you could easily use just about anything you can get input from to control the robot. Here is a snippet of a program that uses an XBox controller.

 private void GamePadAxisUpdated(UpdateAxes update)
        {
            LogInfo("Right x: " + (update.Body.Rx*.001).ToString(CultureInfo.InvariantCulture));
            LogInfo("Right y: " + (update.Body.Ry * .001).ToString(CultureInfo.InvariantCulture));
            LogInfo("Right z: " + (update.Body.Rz * .001).ToString(CultureInfo.InvariantCulture));
            LogInfo(" Left x: " + (update.Body.X * .001).ToString(CultureInfo.InvariantCulture));
            LogInfo(" Left y: " + (update.Body.Y*.001).ToString(CultureInfo.InvariantCulture));
            LogInfo(" Left z: " + (update.Body.Z * .001).ToString(CultureInfo.InvariantCulture));


            var req = new SetDriveRequest {LeftPower = (update.Body.Rx*.0005), RightPower = (update.Body.Y*-.0005)};

            drivePort.DriveDistance(req);
        }

You can easily imagine that we are using a keyboard or mouse or whatever. That fact is it's simple though.

see the whole thing here https://github.com/r0k3t/NxtMSRDS_XboxController

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top