Getting Sensor type

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, imaqine, 99jonathan

Elnof
New User
Posts: 8
Joined: Mon Jun 25, 2007 10:44 pm

Getting Sensor type

Postby Elnof » Wed Jul 18, 2007 3:21 pm

Is it possible to get the type of a sensor? So you could run the same program all the time, but have the sensors plugged in in any port? I was thinking something like this:

Code: Select all

String sensorPortOne = Sensor.S1.getSensorType();

lawrie
leJOS Team Member
Posts: 949
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Wed Jul 18, 2007 10:03 pm

You cannot get the sensor type for Analog/digital sensors like the Touch, Light and Sound sensor. If you are using I2C sensors like the Ultrasonic sensor or those from HiTechnic or mindsensors there are methods in the I2CSensor class to get the manufacturer, type, etc.

This question has been answered before.

Elnof
New User
Posts: 8
Joined: Mon Jun 25, 2007 10:44 pm

Postby Elnof » Thu Jul 19, 2007 9:59 pm

I know. But every time I've seen it it's been:

Code: Select all

SomeSensor bob = new SomeSensor();
bob.getSensorType();


I was wondering if you could do

Code: Select all

Sensor.S1.getSensorType();


Return to “NXJ Software”

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests