本文整理汇总了Java中lejos.hardware.port.SensorPort.S1属性的典型用法代码示例。如果您正苦于以下问题:Java SensorPort.S1属性的具体用法?Java SensorPort.S1怎么用?Java SensorPort.S1使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类lejos.hardware.port.SensorPort
的用法示例。
在下文中一共展示了SensorPort.S1属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
SensorMode touch = touchSensor.getTouchMode();
float[] sample = new float[touch.sampleSize()];
RegulatedMotor m = new EV3LargeRegulatedMotor(MotorPort.A);
m.resetTachoCount();
m.rotateTo(320, true);
// int angle = m.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
// m.rotateTo(-100, true);
// do{
// touch.fetchSample(sample, 0);
// } while (sample[0] == 0);
while (m.isMoving())
Thread.yield();
m.stop();
int angle = m.getTachoCount(); // should be < -100
lcd.drawInt(angle, 0, 1);
// keys.waitForAnyPress();
}
示例2: EV3Helper
/**
* Instantiates a new helper class and optionally calibrates the cannon.
* Robot is ready for operation after completion.
* @param skipMotorCannonCalibration Set to true if you don't want to calibrate the cannon
*/
public EV3Helper(boolean skipMotorCannonCalibration) {
motorRight = new EV3LargeRegulatedMotor(MotorPort.A);
motorLeft = new EV3LargeRegulatedMotor(MotorPort.B);
//Sets default motor speed for driving motors
motorRight.setSpeed(DEFAULT_MOTOR_SPEED);
motorLeft.setSpeed(DEFAULT_MOTOR_SPEED);
motorCannon = instantiateMotorCannon(skipMotorCannonCalibration);
irSensor = new EV3IRSensor(SensorPort.S1);
colorSensor = new EV3ColorSensor(SensorPort.S4);
rangeSampler = irSensor.getDistanceMode();
lastRange = new float[rangeSampler.sampleSize()];
colors = getColors();
}
示例3: main
public static void main(String[] args) {
sensor = new EV3ColorSensor(SensorPort.S1);
sensor.setFloodlight(false);
LCD.drawString("Init", 2, 2);
LCD.setAutoRefresh(false);
brightnessSensorMode = sensor.getRGBMode();
float[] sample = new float[brightnessSensorMode.sampleSize()];
while(true) {
brightnessSensorMode.fetchSample(sample, 0);
LCD.refresh();
LCD.clear();
System.out.println("R: " + sample[0] + " G: " + sample[1] + " B: " + sample[2]);
LCD.drawString("R: " + sample[0], 1, 1);
LCD.drawString("G: " + sample[1], 1, 2);
LCD.drawString("B: " + sample[2], 1, 3);
}
}
示例4: getSensorPort
private static Port getSensorPort(String p) throws EV3ScriptException {
switch (p) {
case "1":
case EV3Constants.S1:
return SensorPort.S1;
case "2":
case EV3Constants.S2:
return SensorPort.S2;
case "3":
case EV3Constants.S3:
return SensorPort.S3;
case "4":
case EV3Constants.S4:
return SensorPort.S4;
}
throw new EV3ScriptException(EV3ScriptException.INVALID_SENSOR_PORT, MapBuilder.buildHashMap("port", p).build());
}
示例5: EventGrab
private EventGrab(){
//left = new EV3LargeRegulatedMotor(MotorPort.A);
//right = new EV3LargeRegulatedMotor(MotorPort.B);
//touchSensor = new TouchSensor(SensorPort.S1);
//touchSensor.start();
infraredSensor = new InfraredSensor(SensorPort.S1);
}
示例6: GrabBot
private GrabBot(){
left = new EV3LargeRegulatedMotor(MotorPort.A);
right = new EV3LargeRegulatedMotor(MotorPort.B);
touch = new EV3TouchSensor(SensorPort.S1);
arbitrator = new Arbitrator(new Behavior[]{forward, hit});
}
示例7: GrabBot
private GrabBot(){
left = new EV3LargeRegulatedMotor(MotorPort.A);
right = new EV3LargeRegulatedMotor(MotorPort.B);
touch = new EV3TouchSensor(SensorPort.S1);
Behavior forward = new ForwardBehavior(this);
Behavior hit = new ObstacleBehavior(this);
arbitrator = new Arbitrator(new Behavior[]{forward, hit});
}
示例8: setupSensors
void setupSensors() {
logger.trace("setupSensors");
leftTouch = new EV3TouchSensor(SensorPort.S1);
rightTouch = new EV3TouchSensor(SensorPort.S4);
distance = new EV3UltrasonicSensor(SensorPort.S2);
distance.enable();
distanceSampler = distance.getDistanceMode();
}
示例9: main
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
SensorMode touch = touchSensor.getTouchMode();
float[] sample = new float[touch.sampleSize()];
RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
mA.resetTachoCount();
mB.resetTachoCount();
mC.resetTachoCount();
mA.rotateTo(760);
int angle = mA.getTachoCount(); // should be -360
lcd.drawInt(angle, 0, 0);
keys.waitForAnyPress();
mB.setSpeed(720);// 2 RPM
mC.setSpeed(720);
mB.forward();
mC.forward();
Delay.msDelay(1000);
mB.stop();
mC.stop();
mB.rotateTo(360);
mB.rotate(-720, true);
while (mB.isMoving())
Thread.yield();
angle = mB.getTachoCount();
lcd.drawInt(angle, 0, 1);
mA.rotateTo(-100, true);
do{
touch.fetchSample(sample, 0);
} while (mA.isMoving() && sample[0] == 0);
mA.stop();
angle = mA.getTachoCount(); // should be -360
lcd.drawInt(angle, 0, 2);
keys.waitForAnyPress();
}
示例10: EV3DevSensorDeviceChild
public EV3DevSensorDeviceChild(){
super(SensorPort.S1,"demo");
}