Using LEGO Mindstorms from DICE

Very brief notes on communicating with NXT LEGO Mindstorms via Bluetooth from DICE.

You machine in question must have the <dice/options/mindstorms-client.h> header and have been rebooted (or bluetooth manually started with /etc/init.d/bluetooth start). You must then have inserted a bluetooth dongle, turned on the NXT module and enabled bluetooth.

Compile some NBC code:

    [user@host ~]$ nbc -Ottt.rtm ttt.nbc

For further options do nbc -help. The example below compiles some NXC code instead, the process after creating a .rtm file is identical however:

    [user@host ~]$ nbc -O=struct.rtm struct.nxc

Scan bluetooth to find out the NXT address (can also do hcitool scan):

    [user@host ~]$ NXTRC -s
    00:16:53:09:92:F5  NXT

The above might take a number of seconds to complete - the address beside NXT is the one you want for future commands.

Request battery level - this is really just to initiate the device bonding - during this command the NXT module should prompt you to enter a PIN and then you should get a window appear on the DICE box to confirm that PIN:

    [user@host ~]$ NXTRC -a 00:16:53:09:92:F5 -b
    =: Battery Level: 7768mV

Now send the compiled code to the module:

    [user@host ~]$ NXTRC -a 00:16:53:09:92:F5 -w ttt.rtm
    =: ** Writing File <ttt.rtm> on NXT
    =: File: <ttt.rtm>  Size: 2422
    =: File written - Size=2422 bytes

Finally run the code on the module:

    [user@host ~]$ NXTRC -a 00:16:53:09:92:F5 -p ttt.rtm
    =: ** Running Program <ttt.rtm>

For further options just use the NXTRC command on its own.

To undo pairing on the NXT module select Bluetooth, My Contacts, HOSTNAME.inf,ed,ac,uk, then left arrow and select trashcan to delete association.

The ttt.nbc file and struct.nxc to compile can be downloaded below:

-- TimColles - 19 Dec 2008

Topic revision: r1 - 19 Dec 2008 - 14:05:12 - TimColles
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
This Wiki uses Cookies