Trouble setting color sensor lamp to white

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

Moderators: roger, 99jonathan, imaqine

Trouble setting color sensor lamp to white

Postby clintonb » Mon Nov 21, 2011 5:15 pm

Greetings.

I am having difficulty setting the the lamp on a LEGO color sensor to white, with a slighty-modified version of Enchanting 0.0.9. [The modifications should not have any effect on the color sensor].

When I run the ColorSensorTest.java sample, it works fine, and I can set the lamp white (and red, green, blue, and off).

Here is the simplest test code I can come up with:

Code: Select all
import lejos.nxt.*;
import lejos.robotics.Color;

public class SimpleColorTest
{   
    public static final void delay(float seconds) {
       Sound.pause( (int)(1000.0f * seconds) );  // time in milliseconds
    }

    public static void main(String [] args) throws Exception
    {
        ColorSensor S1 = new ColorSensor(SensorPort.S1);
   
        while (true) {
            S1.setFloodlight(Color.NONE);   delay(1.0f);
            S1.setFloodlight(Color.RED);    delay(1.0f);
            S1.setFloodlight(Color.GREEN);  delay(1.0f);
            S1.setFloodlight(Color.BLUE);   delay(1.0f);
            S1.setFloodlight(Color.WHITE);  delay(2.0f);   
        }
    }
}


What I find is that the lamp does not turn on white when I tell it to. (It does blink on white for an instant before I set the next color. Changing how long it is supposed to be white has no effect). Every other color works fine.

This seems so simple. Does anyone else get the unexpected result? What am I doing wrong?

Thanks,
Clinton
clintonb
Active User
 
Posts: 80
Joined: Fri May 28, 2010 1:44 am
Location: Cardston, Alberta, Canada

Re: Trouble setting color sensor lamp to white

Postby gloomyandy » Mon Nov 21, 2011 6:27 pm

Hi,
There is no actual white flood light, it is white only because the NXt rapidly switches between red/blue/green, it will only do this when actually reading the sensor....

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Trouble setting color sensor lamp to white

Postby clintonb » Mon Nov 21, 2011 10:54 pm

Ah, thank you Andy. That makes a lot of sense!

Clinton
clintonb
Active User
 
Posts: 80
Joined: Fri May 28, 2010 1:44 am
Location: Cardston, Alberta, Canada


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff