Subject:
|
Re: rotation sensor question
|
Newsgroups:
|
lugnet.robotics.rcx.java
|
Date:
|
Tue, 31 Jul 2001 00:33:53 GMT
|
Viewed:
|
2805 times
|
| |
| |
I don't know the answer to your specific question, but there is more
information about the rotation sensor in the tinyvm-discussion archives, which
you can find from lejos.sourceforge.net by clicking on mailing lists.
The rotation sensor has trouble keeping up with a rapid rotation rate as when
driven by a motor, so some trickery is required to use it.
good luck
Roger
In lugnet.robotics.rcx.java, Paul Perry writes:
> I installed leJOS, got it up and running, then read on the sourceforge site
> a support question about the rotation sensor, so I decided to test it out.
> I wrote a first cut at it and it didn't work, just like the support question
> suggested:
>
> import josx.platform.rcx.*;
> public class Bot
> implements SensorConstants
> {
> public static void main (String[] arg)
> throws Exception
> {
> Sensor.S2.setTypeAndMode (SENSOR_TYPE_ROT, SENSOR_MODE_ANGLE);
> Sensor.S2.activate();
>
> for(;;) {
> LCD.showNumber(Sensor.S2.readValue());
> }
> }
> }
>
> Then I decided to read the fine manual, and tried it again:
>
> import josx.platform.rcx.*;
>
> public class Bot2
> implements SensorConstants
> {
> public static void main (String[] arg)
> throws Exception
> {
> // Sensor.S2.setTypeAndMode (3, 0x80);
> Sensor.S2.setTypeAndMode (SENSOR_TYPE_ROT, SENSOR_MODE_ANGLE);
> Sensor.S2.activate();
> Sensor.S2.addSensorListener (new SensorListener(){
> public void stateChanged (Sensor src, int oldValue, int newValue) {
> LCD.showNumber (newValue);
> try {
> Thread.sleep (100);
> } catch (InterruptedException e) {
> // ignore
> }
> }
> });
> }
> }
>
> And it worked just fine. Good. But why did the first attempt fail?
>
> Thanks, Paul.
|
|
Message is in Reply To:
| | rotation sensor question
|
| I installed leJOS, got it up and running, then read on the sourceforge site a support question about the rotation sensor, so I decided to test it out. I wrote a first cut at it and it didn't work, just like the support question suggested: import (...) (23 years ago, 20-Jul-01, to lugnet.robotics.rcx.java)
|
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|