class RobotModel {

  static final RegulatedMotor leftMotor = new EV3LargeRegulatedMotor(MotorPort.D);
  static final RegulatedMotor rightMotor = new EV3LargeRegulatedMotor(MotorPort.A);

  static final SensorMode lightSensor = new EV3ColorSensor(SensorPort.S2).getRedMode();

  static final float[] light = new float[lightSensor.sampleSize()];
}
Example #2
0
  public void test() {

    EV3ColorSensor sensor = new EV3ColorSensor(SensorPort.S1);

    // 模式一:ColorID,一个数
    // SensorMode mode = sensor.getColorIDMode();
    // 模式二:RGB,三个数
    // SensorMode mode = sensor.getRGBMode();
    // 模式三:环境光,一个数,大则亮,小则暗
    // SensorMode mode = sensor.getAmbientMode();
    // 模式四:测量,一个数,大则近,0则远
    SensorMode mode = sensor.getRedMode();

    float[] samples = new float[mode.sampleSize()];

    while (!Button.DOWN.isDown()) {
      mode.fetchSample(samples, 0);
      int k = 0;
      for (float v : samples) log.echo("v[" + (k++) + "]=" + v);
    }
    sensor.close();
  }
Example #3
0
 /**
  * �Z���T�[�l���擾
  *
  * @return float[] �f�[�^���i�[���ꂽfloat�^�z��
  */
 public float[] getValue() {
   float[] result = new float[mode.sampleSize()];
   mode.fetchSample(result, 0);
   return result;
 }