Getting Sensor type

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

Moderators: 99jonathan, roger, imaqine

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();
Elnof
New User
 
Posts: 8
Joined: Mon Jun 25, 2007 10:44 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.
lawrie
leJOS Team Member
 
Posts: 929
Joined: Mon Feb 05, 2007 1:27 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();
Elnof
New User
 
Posts: 8
Joined: Mon Jun 25, 2007 10:44 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff