You can hook multiple sensors up to the same port if they use whats called I2C, which is a communication protocol. I2C lets you send and receive bytes of information between the sensor and the NXT. Only the sonar sensor that comes with the Lego kit is I2C capable, other special sensors can be bought from third party sellers.

Each I2C sensor is given an unique address and when a command is sent to that address, the sensor will carry out the command. You can hook up any number if I2C sensors onto one port, but each port is limited to one non I2C sensor, such as the touch or light sensors. Note you have to write special code to use the sonar sensor in I2C mode, it normally is used in analog mode.

You can also use multiplexers with the NXT. There are different multiplexers out that will work with the NXT. Usually they use I2C and you send commands to the multiplexer.

Here are some third part sellers of NXT compatible sensors. Not all of them are I2C sensors, many operate just like a light sensor.

Im confused about your second question, are you asking how to make a cable to hook up multiple sensors? You dont have to alter any cables to this this. You could, but one nice product iv seen is the mindsensors port spliter. You can plug one end into the NXT and it creates three more ports, very nice for conecting Lego and I2C sensors to the same port. You can also make your own, I posted mine on my page. It turned out fairly well being my first custom circuit board. All you need to do is make shure is all the ports are wired in parallel to each other. Did I answer your question?

Note: I've fixed the following problem. Well, more accurately, I ran the program again and now it's working. Strange. But I'll leave the full message here in case anybody needs code that will run 2 sensors like this.

I'm wanting to do a similar thing.
I've purchased a Port splitter from Mindsensors, and I can use it with a Mindsensors Compass and Accelerometer. But I was hoping it would be possible to use a Touch sensor and Compass sensor on the same port.
The program I've editted goes as follows:

Code:

/*Utility program to use with mindsensors.com CMPS-Nx V2.0 compass sensor.For use with RobotC 1.0.08 or higher.This Demo uses the address of 0x02 for the CMPS-Nxassuming NxT screen with 0.1 degree resolution

////////////////////////////////////////////////////////////////////////////////// Display the heading and touch state on Nxt screen///////////////////////////////////////////////////////////////////////////////

The Touch gives me a consistent correct reply. In or Out. However, the compass sensor constantly flicks back and forth between "Error" and "Read OK"; and it's difficult to pick up the actual readings, but generally either 25, 0 or -25. Perhaps occasionally, an actual compass reading, but I cannot be sure.

Anybody's help or advice on this is deeply appreciated, Kit.

Edit: Also, the same program works 100% if only one of either sensor is plugged in.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum