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