/* * This program version begins with testing how sensation works, and moves the * thing forward. * * ******************* * Julie Powers-Boyle * 20060215 Wed, Programming WS * $ID * ******************* */ import josx.platform.rcx.*; public class SimpleNav implements SensorConstants{ public static void main (String[] args) throws InterruptedException { //Don't run away until someone says to do so Button.RUN.waitForPressAndRelease(); Sensor.S2.setTypeAndMode(SENSOR_TYPE_LIGHT, SENSOR_MODE_PCT); Sensor.S2.activate(); String lightText = "100"; int lightValue = 100; //Now start moving forward when there's something dark while (lightValue > 75){ lightValue = Sensor.S2.readValue(); lightText = Integer.toString(lightValue); TextLCD.print (lightText); Motor.A.forward(); Motor.C.forward(); Thread.sleep(1000); } Motor.A.stop(); Motor.C.stop(); Button.RUN.waitForPressAndRelease(); } }