当前位置: 首页>>代码示例>>Java>>正文


Java SensorPort.S1属性代码示例

本文整理汇总了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();
	}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:31,代码来源:MotorDemo03.java

示例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();
}
 
开发者ID:magnusbae,项目名称:HelloBrick,代码行数:22,代码来源:EV3Helper.java

示例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);

    }

}
 
开发者ID:phllipo,项目名称:RoboRace,代码行数:20,代码来源:LightTestMain.java

示例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());
}
 
开发者ID:jbenech,项目名称:gnikrap,代码行数:17,代码来源:SimpleEV3Brick.java

示例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);
}
 
开发者ID:jweijers,项目名称:EV3-robots,代码行数:7,代码来源:EventGrab.java

示例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});
}
 
开发者ID:jweijers,项目名称:EV3-robots,代码行数:7,代码来源:GrabBot.java

示例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});
}
 
开发者ID:jweijers,项目名称:EV3-robots,代码行数:9,代码来源:GrabBot.java

示例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();
}
 
开发者ID:RadicalZephyr,项目名称:ev3java,代码行数:9,代码来源:Main.java

示例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();
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:45,代码来源:MotorDemo06.java

示例10: EV3DevSensorDeviceChild

public EV3DevSensorDeviceChild(){
    super(SensorPort.S1,"demo");
}
 
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:3,代码来源:EV3DevSensorDeviceTest.java


注:本文中的lejos.hardware.port.SensorPort.S1属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。