This is a guide to using the motors and sensors from the LEGO NXT set with a Parallax Basic Stamp II or BS2.  However, rather than just providing schematics and sample code for the BS2, I'll be providing some theory on how the sensors work as well.  This way, someone using an arduino or other microcontroller should find this guide at least somewhat helpful.

My two main sources of information are
The LEGO Hardware Developer Kit  http://mindstorms.lego.com/en-us/support/files/default.aspx
TheCompBlog: Hacking the NXT http://www.thecompblog.com/2012/07/hacking-lego-nxt-part-1.html
-The latter is a decent guide if you're using an arduino.  But take note that his schematics often show pins 2 and 3 connected to +5V instead of ground.  Pins 2 and 3 are ground for all of the sensors except the button which is just a switch.

Have any suggestions?  Is something difficult to understand, incorrect, or missing?  Leave a comment and I'll see what I can do.  I would like this instructables to be a comprehensive guide on using the BS2 with the NXT set.  If you're using a different microcontroller and you're stuck, I may or may not be able to help but it doesn't hurt to ask.

I hope to get an arduino soon, and if this guide does well I will post a complimentary guide for using the arduino with sample codes for that.  Let me know if you'd like that.

Step 1: NXT Cables

First and foremost, we need to connect our NXT hardware to our microcontroller.  There are a few ways of going about this.
I opted for stripping a set of NXT cables I ordered from http://mindsensors.com.  I split up the wires, stripped them, soldered short lengths of solid-core wiring onto each, heatshrunk each solder joint, and heatshrunk the whole bundle of wires, creating a connector.
-In hindsight, you can buy one long wire and make two spliced wires out of it by cutting it in the middle.
-Also, make sure you keep your wires in order.  The NXT wires are color-coded but the mindsensors wires are not.
-Some people have made modified RJ-12 cables and others have just worked with the originals.
Another option is to buy a female jack from mindsensors which requires little to no messing around with a soldering iron and looks a lot cleaner.

Wires are numbered from the latch side right-to-left, so the wire nearest the latch is 1 and the wire farthest from the latch is 6.  
LEGO color codes them as follows:
(See image for reference)

About This Instructable


25 favorites


More by carrick149: Using NXT Components with a Micro Controller
Add instructable to: