-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
After transferring the following source code from LeJOS to ev3dev the LocalEV3-Class is not compatible.
package colorSensor;
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import ev3dev.sensors.ev3.EV3ColorSensor;
import lejos.hardware.Key;
import lejos.hardware.port.MotorPort;
import lejos.hardware.port.SensorPort;
import lejos.utility.Delay;
public class Ev3devColorSensorRedMode {
public static void main(String[] args) {
EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.S1);
colorSensor.setCurrentMode("Red");
float[] sample = new float[colorSensor.sampleSize()];
/* HERE */ Key esc = LocalEV3.get().getKey("Escape"); /* HERE */
EV3LargeRegulatedMotor motor = new EV3LargeRegulatedMotor(MotorPort.A);
motor.setSpeed(80);
while (esc.isUp()) {
colorSensor.fetchSample(sample, 0);
System.out.println(sample[0]);
if (sample[0] > 0.5) {
motor.stop();
} else {
motor.forward();
}
Delay.msDelay(1000);
}
motor.close();
}
}