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
