Subject:
|
lejos program terminating immediately
|
Newsgroups:
|
lugnet.robotics.rcx.java
|
Date:
|
Wed, 10 Aug 2005 15:10:31 GMT
|
Viewed:
|
6677 times
|
| |
| |
Hi,
I'm trying to use leJOS to display the current value of the rotation sensor I
have hooked up to Sensor Port 1, but when I run the program, the RCX just beeps
and ends the program immediately. Here's my code:
import josx.platform.rcx.*;
public class Rot_test
{
public static void main (String[] args) throws Exception
{
Sensor.S1.setTypeAndMode (SensorConstants.SENSOR_TYPE_ROT,
SensorConstants.SENSOR_MODE_ANGLE);
Sensor.S1.addSensorListener(new SensorListener() {
public void stateChanged(Sensor aSource, int aOldValue, int
aNewValue){
LCD.clear();
Integer i = new Integer(aNewValue);
String s = i.toString();
TextLCD.print(s);
}
});
Sensor.S1.activate();
}
}
I have a question about leJOS that may be related to this (and I think it may
have to do with the problem I'm having). When a leJOS program is set up, and
the program finishes executing all of the code in the main(String[] args)
method, does the program just end?
I think the problem with my code may be that I set up the listeners, but after
the program finishes reading all of the code in the method, it just exits and
never watches the rotation sensor.
Does anyone know why I'm having this problem or what it is?
Thanks,
Jason
|
|
Message has 1 Reply:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|