Problems with ProxmimitySensor Class

This is where you talk about the RCX software itself, installation issues, and programming talk.

Moderator: roger

New User
Posts: 4
Joined: Thu Apr 24, 2008 7:01 pm

Problems with ProxmimitySensor Class

Postby ltj » Wed May 07, 2008 6:55 pm


i have problem with using ProximitySensor class, here is the code:

Code: Select all

import josx.platform.rcx.Motor;
import josx.platform.rcx.Sensor;
import josx.platform.rcx.ProximitySensor;
import josx.platform.rcx.LCD;
import josx.platform.rcx.TextLCD;

public class Proximity {
   public static void main (String[] args) throws InterruptedException {
      ProximitySensor ps2 = new ProximitySensor (Sensor.S2);
      Motor.A.forward ();
      Motor.C.forward ();
      ps2.waitTillNear (0);
      TextLCD.print ("dupa");
      Motor.C.backward ();
      Thread.currentThread ().sleep (3000);
      Motor.A.stop ();
      Motor.C.stop ();


my point was that robot should run forward, when object appears it should rotate and stop, but all it do is rotate even if nothing is in its way

Edit: please can someone at least post any working example that uses ProximitySensor Class.
I'm using lejos 2.1.0 can it be a problem, should i upgrade to newer version?

Return to “RCX Software”

Who is online

Users browsing this forum: No registered users and 0 guests