import lejos.nxt.*; /** seeing if readValue results CHANGE after calibrateHigh() and calibrateLow() are called..? @author Sharon Tuttle @version 2015-03-12 **/ public class LightSensorTest2 { /** try to calibrate high and low FIRST, and then read several values from a now-calibrated light sensor and print the results to the LCD screen @param args not used **/ public static void main(String[] args) { // see what kind of results these methods return // PRE-calibration LightSensor myLightSensor = new LightSensor(SensorPort.S3); System.out.println("readValue: " + myLightSensor.readValue()); System.out.println("getLow: " + myLightSensor.getLow()); System.out.println("getHigh: " + myLightSensor.getHigh()); Button.waitForAnyPress(); // now calibrate the light sensor LCD.clear(); LCD.drawString("set on DARK surface", 0, 0); Button.waitForAnyPress(); myLightSensor.calibrateLow(); LCD.drawString("calibd LOW", 0, 1); Button.waitForAnyPress(); LCD.clear(); LCD.drawString("set on LIGHT surface", 0, 0); Button.waitForAnyPress(); myLightSensor.calibrateHigh(); LCD.drawString("calibd HI", 0, 1); Button.waitForAnyPress(); // what do getLow and getHigh return after // calibration? LCD.clear(); System.out.println("NOW: "); System.out.println("getLow: " + myLightSensor.getLow()); System.out.println("getHigh: " + myLightSensor.getHigh()); Button.waitForAnyPress(); // see what kind of light sensor readings you get // for 4 trials using the now-calibrated light // sensor LCD.clear(); for (int i=0; i<4; i++) { LCD.drawString("" + (1+i) + " of 4: set it", 0, 2*i); Button.waitForAnyPress(); LCD.drawString("readValue: " + myLightSensor.readValue(), 0, (2*i)+1); } Button.waitForAnyPress(); } }