NXT 2.0 Color Sensor

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderators: roger, 99jonathan, imaqine

NXT 2.0 Color Sensor

Postby vstarsal » Mon Feb 11, 2013 3:12 pm

I can not get any readings other than 100 for getLightvalue or 1023 for getNormalizedLightValue. It doesn't matter if I expose the sensor to bright light or darkness. I also cannot turn on any LED. I have tried everything I can think of. I have setFloodlight(0) for the red LED, but nothing. I have tried the sensor in SensorPort(S.1) and in S.3, but neither works. I cannot find any code that shows how to get this working. Can you help?
vstarsal
New User
 
Posts: 2
Joined: Mon Feb 11, 2013 3:04 pm

Re: NXT 2.0 Color Sensor

Postby PallottiSoccerPLayer » Mon Feb 11, 2013 6:06 pm

Please post what you've programmed. Could be useful...

Did you test several colour sensors? Maybe your one is broken.
PallottiSoccerPLayer
New User
 
Posts: 5
Joined: Sat Feb 09, 2013 6:21 pm

Re: NXT 2.0 Color Sensor

Postby vstarsal » Mon Feb 11, 2013 8:45 pm

Hi
My most recent code is below.

public static void main(String[] args) {
System.out.println("Press ENTER to begin program.");
Button.ENTER.waitForPressAndRelease();

LightSensor ld = new LightSensor(SensorPort.S3);

ld.setFloodlight(0);
System.out.println("Normal " + ld.readNormalizedValue());
System.out.println("Reg value " + ld.readValue());
System.out.println("Get value " + ld.getLightValue());
System.out.println("Get Normal value " + ld.getNormalizedLightValue());
Button.ENTER.waitForPressAndRelease();
}//end main

But...
I also tried using SensorPort.S1. I also tried using LightDetector and ColorSensor
LightSensor ld = new LightSensor(SensorPort.S1);
LightDetector ld= new ColorSensor(SensorPort.S3);
ColorSensor ld = new ColorSensor(SensorPort.S3);
ld.setFloodlight(true);
vstarsal
New User
 
Posts: 2
Joined: Mon Feb 11, 2013 3:04 pm

Re: NXT 2.0 Color Sensor

Postby gloomyandy » Mon Feb 11, 2013 8:55 pm

If you have the new color sensor you need to use the ColorSensor class not the LightSensor class. LightSensor is for the sensor supplied with the original version of the NXT set...

Take a look at the ColorSensorTest sample application for more details of how you can use this sensor.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff