Example Code

Send Data from Computer to NXT

Code and Documents

Attachment

Download All

Introduction

This example will command the NXT to read the color sensor and send what color it read to the computer in the form of a number.  At this point, the computer will display what color was sensed and send that data back to the NXT in the form of a string.  This srting is then displayed on the NXT brick display screen.  This is a great example in sending and receiving data from the NXT brick.

NXTbd.png

Steps to Complete

Connect color sensor to Port 3 on the NXT Brick.  Connect the NXT to the Computer either through USB or bluetooth.  Deploy the NXT code and get it running on the NXT.  Then run the Host code and see the indicator displaying the color that was determined by the sensor.

Additional Notes

This example can easily be modified to fit your specific application, but can be used to show the simplicity of data communication using LabVIEW.

National Instruments
Applications Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Sousuke
Member
Member
on

I am looking into getting a Mindstorm for the use in a research lab. One application we wish to do is a realtime control of a physical limit. That would require a simmular computer to NXI communication where the computer user gives a new position for the motor to move too.

I see that you are using the Bluetooth connection. Is a Bluetooth connection the only way to have this two way communication?

I have not been able to install the model and poke around myself. Currently I am just evaluating the option of getting a Mindstorm for the lab. Thank you for your time.

Peerformance
Member
Member
on

If i try to start the PC Host vi, (with computer as target) I get an error “Error communicating with NXT Shell”, maybe because the NXT Client vi is still running on the NXT??? What did I wrong? How to do right? And how can you know that the NXT is on the (client) line 1??? If somebody know answers, it would be very helpful for me.   

Claire_Reid
NI Employee (retired)
on

Hi Peerformance-

Please post your question to the

Regards

Claire Reid

Regards,
Claire Reid
National Instruments
Contributors