User Tools

Site Tools


nxt_pc_bluetooth

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
nxt_pc_bluetooth [2016/09/27 14:22] alvaropintadonxt_pc_bluetooth [2016/10/23 19:58] (current) dwallace
Line 1: Line 1:
-====== Lego Bluetooth Tutorial ======+====== NXT Bluetooth Communication Tutorial ======
  
 **Author:** Alvaro Pintado Email: <pintado@unlv.nevada.edu> \\ **Author:** Alvaro Pintado Email: <pintado@unlv.nevada.edu> \\
Line 9: Line 9:
   * Windows 10   * Windows 10
   * Visual Studio 15   * Visual Studio 15
-  * Intermediate experience with C++ programming (Classes, objects, pointers)+  * Intermediate experience with Cpp programming (Classes, objects, pointers)
   * Basic LEGO NXT Tribot   * Basic LEGO NXT Tribot
  
Line 46: Line 46:
 **Note:** See documentation for more commands and details about the LEGO NXT Communication Protocol {{:alvarop:appendix_2-lego_mindstorms_nxt_direct_commands.pdf| NXT Direct Commands}} **Note:** See documentation for more commands and details about the LEGO NXT Communication Protocol {{:alvarop:appendix_2-lego_mindstorms_nxt_direct_commands.pdf| NXT Direct Commands}}
  
-There are several methods you can you go about sending direct commands. There are programs that allow you to send data to certain COM ports, but most of these are only good for testing and not writing programs that utilize the COM ports. This tutorial will demonstrate the use of the C++ Serial Port class in Windows that can be used to write programs that send data to COM ports, thus allowing the user to send direct commands to the NXT Brick with a C++ program.+There are several methods you can you go about sending direct commands. There are programs that allow you to send data to certain COM ports, but most of these are only good for testing and not writing programs that utilize the COM ports. This tutorial will demonstrate the use of the C-plus-plus Serial Port class in Windows that can be used to write programs that send data to COM ports, thus allowing the user to send direct commands to the NXT Brick with a C-plus-plus program.
  
-<code>+<code c++ NXTBluetooth.cpp>
 /* /*
 Alvaro Pintado Alvaro Pintado
Line 117: Line 117:
  // See LEGO Mindstorms NXT Communication Protocol documentation for details  // See LEGO Mindstorms NXT Communication Protocol documentation for details
  // motorA = 0, motor b = 1, motor c = 1  // motorA = 0, motor b = 1, motor c = 1
- wchar_t motorL = 2+ wchar_t motorL = [left motor port];  
- wchar_t motorR = 1;+ wchar_t motorR = [right motor port];
  cli::array<wchar_t, 1>^ driveL = { 0x0C, 0x00, 0x00, 0x04, motorL, 0x64, 0x07, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 };  cli::array<wchar_t, 1>^ driveL = { 0x0C, 0x00, 0x00, 0x04, motorL, 0x64, 0x07, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 };
  cli::array<wchar_t, 1>^ driveR = { 0x0C, 0x00, 0x00, 0x04, motorR, 0x64, 0x07, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 };  cli::array<wchar_t, 1>^ driveR = { 0x0C, 0x00, 0x00, 0x04, motorR, 0x64, 0x07, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 };
Line 150: Line 150:
   - Under the "COM Ports" menu are the current COM Ports assigned to different devices. Find the Outgoing Port for the NXT and take note of it. It will be used later in the tutorial.   - Under the "COM Ports" menu are the current COM Ports assigned to different devices. Find the Outgoing Port for the NXT and take note of it. It will be used later in the tutorial.
   - Open the sample code and read through the comments to get a general idea of what the program does   - Open the sample code and read through the comments to get a general idea of what the program does
 +  - Change the values for the motor variables MotorL and MotorR to your NXT Bot's corresponding ports
   - Build and run the the solution, when prompted, enter the COM port that the NXT Brick is currently utilizing   - Build and run the the solution, when prompted, enter the COM port that the NXT Brick is currently utilizing
  
nxt_pc_bluetooth.1475011378.txt.gz · Last modified: by alvaropintado