To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.javaOpen lugnet.robotics.rcx.java in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / Java / 95
94  |  96
Subject: 
rotation sensor question
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Fri, 20 Jul 2001 13:34:39 GMT
Viewed: 
2542 times
  
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 has 2 Replies:
  Re: rotation sensor question
 
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 (...) (23 years ago, 31-Jul-01, to lugnet.robotics.rcx.java)
  Re: rotation sensor question
 
Hi there, (...) What happened? nothing appeared in the LCD? This looks 99% like the example I did yesterday - except that I put in a "LCD.refresh()" after the #showNumber call. I run 1.0.2 RC4 under Linux... // Martin (23 years ago, 4-Sep-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
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR