CSDriver.java
import lejos.nxt.*;
 
public class CSDriver {
 
    public static void main (String[] args) {
 
        ColorSensor sensor = new ColorSensor(SensorPort.S1);
        sensor.calibrate();
        LCD.clear();
        while (! Button.ESCAPE.isPressed()) {
            LCD.drawString("light: " + sensor.light(), 0, 0);
            if (sensor.white()) {
                LCD.drawString("c: white", 0, 1);
            } else if (sensor.blue()) {
                LCD.drawString("c: blue", 0, 1);
            } else if (sensor.black()) {
                LCD.drawString("c: black", 0, 1);
            }
        }
    }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License