AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Connecting to brick through Bluetooth:

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

Connecting to brick through Bluetooth:

Postby mattaseymour » Fri Feb 06, 2009 6:18 pm

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?
mattaseymour
 
Posts: 2
Joined: Fri Feb 06, 2009 6:16 pm

Re: Connecting to brick through Bluetooth:

Postby andrew.kirillov » Fri Feb 06, 2009 8:00 pm

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
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Connecting to brick through Bluetooth:

Postby kodOZANI » Tue Feb 10, 2009 1:37 pm

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 ...
                }
            }
kodOZANI
 
Posts: 3
Joined: Tue Feb 10, 2009 12:57 pm
Location: Turkey

Re: Connecting to brick through Bluetooth:

Postby mattaseymour » Thu Feb 12, 2009 12:48 pm

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.
mattaseymour
 
Posts: 2
Joined: Fri Feb 06, 2009 6:16 pm

Re: Connecting to brick through Bluetooth:

Postby andrew.kirillov » Thu Feb 12, 2009 4:49 pm

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.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework