Strict Standards: Non-static method timezone::is_dst() should not be called statically in /home4/sabre/public_html/textpattern/lib/txplib_misc.php on line 2355

Strict Standards: Non-static method timezone::is_supported() should not be called statically in /home4/sabre/public_html/textpattern/lib/txplib_misc.php on line 2523
Articles: SABRE: Arduino + NXTMMX + LEGO Motors

Arduino + NXTMMX + LEGO Motors

Updated 2010-11-09. It is not much easier to install the library.

When I first learned that Mindsensors.com (who make several really neat sensors for use with the NXT) was making a motor multiplexer, I contacted them to ask if it would work with the Arduino (yes!) … and then I asked if I could buy a prototype and was thrilled when they sent me one. (Thanks!)

This video shows how well it works.

Oh man. I love the NXT, but I really like the possibilities that this affords. The NXTMMX allows you to connect two LEGO motors to a device that issues I2C commands, and gives you one more port to plug in another NXT device. There is a good tech spec documenting the commands, so there is no reason it wouldn’t work with your microcontroller of choice, by merely connecting four wires (with a cable like this, or something from here) and supplying power with a battery pack.

Better than that, though, is that there are other I2C sensors for the NXT which will work. When I run the I2CScanner example sketch, I am able to see a HiTechnic Compass Sensor and a Mindsensor’s Line Leader. Most of my other sensors do not use the I2C bus to communicate and would need to be connected differently to use with an Arduino. [For anyone who wants to try, allow me to recommend Extreme NXT: Extending the LEGO MINDSTORMS NXT to the Next Level, or download the NXT Hardware Development KitLEGO was kind and wise enough to offer schematics on how the parts works.] One I2C sensor that did not work was LEGO’s Ultrasonic sensor. I suspect that if I provided a 9V power signal to it, it would work.

I have started an open-source project called NXT I2C Devices for Arduino. The project contains my initial code to run the NXTMMX (ported from the Not eXactly C API for the device), and, Mindsensors has been contributing code so you can use it with other sensors that they sell!

Update: To use it, create a directory called libraries within your Arduino sketchbook directory. Then, download and extract the latest version of NXTI2CDevice into that folder. (You should end up with a /libraries/NXTI2Device folder within your sketchbook.) Quit and restart the Arduino IDE, and you are ready to go!


If you’d like to aid in development, you’ll need to install the Bazaar version control system to get the latest code. At a command prompt, change to the Arduino library directory (on my Mac it is /Applications/Arduino.app/Contents/Resources/Java/libraries/), and issue this command:

bzr branch lp:nxti2cdevice NXTI2CDevice

If you’d prefer to use a graphical tool, take a look at the first few steps of my previous post explaining the use of Bazaar Explorer with Enchanting. Just make a branch of lp:nxti2cdevice, and then copy/move/symlink the folder into your Arduino libraries folder.

Oh, and if you are interested in helping out on the project, drop me a line.

Happy Hacking!

Posted by Clinton Blackmore - Tuesday November 9, 2010.
Posted in .

Comment

  1. Hi, this looks great. I’ve dabbled a bit with Arduino in the past, but never achieved much. At the moment I have Mindstorms for an art project. I’ve been making drawing robots, as you can see if you care to look at my blog. My next stage is to try to make the NXT motors react to data from the web (RSS feeds etc.), but, newbie that I am, I was stuck until now. Do you think getting rid of the “Brain” brick and doing everything via Arduino and Processing would be a good way to go? I’ve tried out some of Banzi’s sketches where the Arduino reacts to RSS feeds. If you have any advice, or even just a Yea or Nay, I’d be really grateful. Michael

    Michael Feaux · May 19, 03:38 PM · #

  2. Hi Michael.

    It is too bad you didn’t ask a week ago — you could’ve seen this live:
    http://mightor.wordpress.com/2011/05/12/id-rather-be-streaming-robots/ — Xander Soldaat used a Dexter Industries WiFi module for the NXT, and hooked it up to respond to a webserver. It is not clear to me that you can actually purchase the sensor yet, but it would sure be a fun way to go.

    If you are already using Processing, you can remotely control an NXT with it over Bluetooth. See http://www.diegobaca.co.uk/NXT/nxt.html , for example. I think this would be a really good way to go.

    I think getting rid of the brain brick and using the Arduino is not an unreasonable idea, but, as you have an NXT, I’d try out ways to use it as-is first.

    I hope that helps!
    Clinton

    Clinton Blackmore · May 20, 10:41 PM · #

  3. It does! Lots of help, thanks. I’ll let you know when I get something up and running.

    Michael

    Michael Feaux · May 21, 07:54 AM · #

  4. Hi, I am working on a project where I have replaced the NXT with an arduino uno micro controller, interfaced with a NXTMMX multiplexer in order to power two lego motors and any of the lego sensors (ultrasonic, sound, light, or touch). When I run the “readenconders” example from the library, the serial control does recognize the NXTMMX but none of the sensors. What can be possibly the problem?

    — Francisco Hernandez · Nov 17, 05:17 AM · #

  5. Hi Francisco.

    While it has been some time since I’ve worked with this, the library was only designed to work with the NXTMMX. Theoretically, someone could add features to use additional sensors, although it may only be I2C sensors (just the ultrasonic, not the sound, light or touch) that work.

    Mindsensors is doing some neat things with the Arduino; it looks like they may have developed other libraries, that you might be able to use. See here.

    — Clinton Blackmore · Nov 17, 07:36 AM · #

  6. Hi Clinton,

    I’m planning to hook up a few NXT motors to an Arduino directly without using the NXTMMX. It’s not clear how I need to make the connections (+5V, GND, SCL, SDA) and the 9V power supply. Do you have a schematic for this or can you tell me how to connect these signals?? (I use a standard NXT cable and a Connector Socket for NXT for a PCB)

    Arjen

    — Arjen · Nov 10, 05:14 PM · #

  7. I’m sorry, Arjen, this isn’t fresh in my mind, and the note 38 seconds into the video (and perhaps in the source code) is what I’ve got to go by. It looks like it explains most of the connections. I wouldn’t connect the 9V directly to an Arduino — if you want to power it from a battery pack, you should put it through a 5V regulator chip — but you should connect the 9V to the motors, much the same way you would as if you were using the NXTMMX with an NXT.

    Sorry that’s not much help.
    Cheers,
    Clinton

    — Clinton Blackmore · Nov 12, 09:25 AM · #