Page 1 of 1

Connecting to brick through Bluetooth:

PostPosted: Fri Feb 06, 2009 6:18 pm
by mattaseymour
I am looking to control a robot via bluetooth, how do i go about doing this?

Im, going to be using C# but I have never used the bluetooth library, within your documentation you talk about a virtual serial connection. What is this?

Re: Connecting to brick through Bluetooth:

PostPosted: Fri Feb 06, 2009 8:00 pm
by andrew.kirillov
Hello,

mattaseymour wrote:I am looking to control a robot via bluetooth, how do i go about doing this?


Which robot do you use ? Lego RCX or something different ?

mattaseymour wrote:... virtual serial connection. What is this?


It is a common feature of most Bluetooth drivers. After connection to Bluetooth device, it is possible to setup different service, like virtual serial port. The serial port simplifies communication with the device - you just use regular API to open serial port and write/read to/from it.

With best regards,
Andrew

Re: Connecting to brick through Bluetooth:

PostPosted: Tue Feb 10, 2009 1:37 pm
by kodOZANI
I want to add some details to Andrew's post. If you have more than one lego nxt brick, or want to select a COM port from a list the following code block may help.

To list COM ports in the system in to a datagrid view's combo-box
Code: Select all
using System.IO.Ports;

            try
            {
                dgConnectionPort.Items.AddRange(SerialPort.GetPortNames());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

To connect each vehicles with a selected COM port from a datagrid view
Code: Select all
List<NXTDriver> drivers = new List<NXTDriver>();

            for (int i = 0; i < dataGridViewVehicle.RowCount - 1; i++)
            {
                drivers.Add(new NXTDriver(dataGridViewVehicle.Rows[i].Cells["dgConnectionPort"].Value.ToString()));       
                if (!drivers[i].Connect())
               {
                    string vehicleName = dataGridViewVehicle.Rows[i].Cells["dgVehicleName"].Value.ToString();
                    toolStripStatusLabel1.Text += "Unable to connect " + vehicleName;
                    drivers[i] = null;
               }
                else
                {
                  // After connection ...
                }
            }

Re: Connecting to brick through Bluetooth:

PostPosted: Thu Feb 12, 2009 12:48 pm
by mattaseymour
I using the lego mindstorm NXT robot, which I am hoping to join to a pc with a bluetooth connection which will allow me to control it.

Re: Connecting to brick through Bluetooth:

PostPosted: Thu Feb 12, 2009 4:49 pm
by andrew.kirillov
Hello

mattaseymour wrote:I using the lego mindstorm NXT robot,


Then it should not be a problem to connect it to PC using Bluetooth and control it over virtual serial port.

Check that your PC has Bluetooth adapter. If so, then use its software to establish connection to NXT and then create a virtual serial port.