Hi all,

I am trying to caluclulate maximum light level reading from the light sensor 
but all I get is 88 or 87 as the number displayed on the LCD. It appears 
after doing some tests that the first value the readValue() method picks up 
is 88 or 87 at any lighting condition.
My code is shown below. Any help is appreciated.

Thanks.
---------------------------
import josx.platform.rcx.*;

public class LightSeeker {


public static void main(String[] args)
  throws InterruptedException {
        int max_val = 0;
        int current_val;
Sensor.S1.setTypeAndMode(SensorConstants.SENSOR_TYPE_TOUCH,

SensorConstants.SENSOR_MODE_BOOL);

Sensor.S2.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT,

SensorConstants.SENSOR_MODE_PCT);

          Sensor.S2.activate();


          while(Sensor.S1.readBooleanValue() == false) // touch sensor is 
not pressed
          {

                current_val =  
Sensor.S2.readValue();//Sensor.S2.readSensorValue(1,1);
                if (current_val > max_val){
                                                         max_val = current_val;
                                                   }
          } // while loop

        Sensor.S2.passivate();
        Sound.beep();
        LCD.showNumber(max_val);

        Button.RUN.waitForPressAndRelease();

  }
}



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion

Reply via email to