All pastes #1240495 Raw Edit

BWDetection.java

public java v1 · immutable
#1240495 ·published 2008-10-30 11:19 UTC
rendered paste body
import lejos.nxt.*;public class BWDetection {				public static void main(String[] args) {				BlackWhiteSensor bws = new BlackWhiteSensor(SensorPort.S2);							bws.calibrate();					while (!Button.ESCAPE.isPressed())		{   			try			{						Thread.sleep(100);				LCD.clear();				LCD.drawString("Current: ",0,0);				LCD.drawInt(bws.light(), 8, 0);								if(bws.white() )				{					LCD.drawString("white", 0, 1);				}				else if(bws.black() )				{					LCD.drawString("Black: ", 0, 1);									}				else				{									LCD.drawString("Undefined",0,1);				}							}				catch(Exception ex)			{				LCD.clear();				LCD.drawString(ex.getMessage(),0,0);			}		}			}		}