I'm having a number of problems, the first of them being that the robot, once it senses something, doesn't move, and remains still. Though it stops in the direction of the object, showing that the sensor indeed is working...
I'm baffled as to why it doesn't move towards the object though...
Here's my code:
- Code: Select all
import josx.platform.rcx.Motor;
import josx.platform.rcx.LCD;
import josx.platform.rcx.Sensor;
import josx.platform.rcx.Button;
import josx.platform.rcx.Sound;
import josx.robotics.TimingNavigator;
import josx.platform.rcx.ProximitySensor;
public class Proximity
{
public static void main(String[] args) throws InterruptedException
{
ProximitySensor ps = new ProximitySensor(Sensor.S2, 30);
Motor.A.setPower(4);
Motor.C.setPower(4);
Motor.A.forward();
Motor.C.backward();
ps.waitTillNear(0);//Wait for an object to enter range of proximity
Sound.twoBeeps();
Motor.C.forward();
Thread.currentThread().sleep(1000);
}
} // class Proximity
