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


Java MotorPort.C属性代码示例

本文整理汇总了Java中lejos.hardware.port.MotorPort.C属性的典型用法代码示例。如果您正苦于以下问题:Java MotorPort.C属性的具体用法?Java MotorPort.C怎么用?Java MotorPort.C使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在lejos.hardware.port.MotorPort的用法示例。


在下文中一共展示了MotorPort.C属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

public static void main(String[] args) {
	EV3 ev3 = (EV3) BrickFinder.getLocal();
	TextLCD lcd = ev3.getTextLCD();
	Keys keys = ev3.getKeys();

	// lcd.drawString("Hello Trayan", 4, 2);
	// lcd.drawString("from leJOS", 4, 3);

	// Move forward
	RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
	RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
	mB.synchronizeWith(new RegulatedMotor[] { mC });

	mB.startSynchronization();
	mB.forward();
	mC.forward();
	mB.endSynchronization();

	Delay.msDelay(3000);
	mB.startSynchronization();
	mB.stop();
	mC.stop();
	mB.endSynchronization();

	// keys.waitForAnyPress(5000);
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:26,代码来源:MoveRobot.java

示例2: calibrateMotorCannon

/**
 * Calibrates the cannon and puts it in a read-to-fire state.
 */
private void calibrateMotorCannon() {
  UnregulatedMotor motor = new UnregulatedMotor(MotorPort.C);
  motor.setPower(50);

  int maxIterations = 40;
  int lastTachoCount = 0;
  while (maxIterations-- > 0) {
    Delay.msDelay(100);
    int newTachoCount = motor.getTachoCount();
    if (newTachoCount == lastTachoCount) {
      break;
    }
    lastTachoCount = newTachoCount;
  }

  motor.close();
}
 
开发者ID:magnusbae,项目名称:HelloBrick,代码行数:20,代码来源:EV3Helper.java

示例3: init

public void init(boolean isClockwiseMove) {
	this.robotRunning = true;
	
	//Init Motor
	motorA = new EV3MediumRegulatedMotor(MotorPort.A);
	motorB = new EV3LargeRegulatedMotor(MotorPort.B);
	motorC = new EV3LargeRegulatedMotor(MotorPort.C);
	
	// init sensors
	this.colorSensor = new EV3ColorSensor(SensorPort.S3);
	//For reading color only
	try {
		this.colorSensorRGB = new EV3ColorSensor(SensorPort.S2);
	} catch(Exception e) {
		this.colorSensorRGB = null;
	}
	new Thread(new ColorIdentifyTask()).start();
	new Thread(new LightIdentifyTask()).start();
}
 
开发者ID:eSDK,项目名称:esdk_ide_ev3,代码行数:19,代码来源:HDCIDERobot.java

示例4: main

public static void main(String[] args) {
    LCD.drawString("Hello world", 2, 3);
    Button.waitForAnyPress();
    EV3MediumRegulatedMotor ev3MediumRegulatedMotor = new EV3MediumRegulatedMotor(MotorPort.C);
    resetSmallEngine(ev3MediumRegulatedMotor);
    grab(ev3MediumRegulatedMotor);
    LCD.drawString("Position: " + ev3MediumRegulatedMotor.getPosition(), 2, 3);
    resetSmallEngine(ev3MediumRegulatedMotor);

    Button.waitForAnyPress();
}
 
开发者ID:jweijers,项目名称:EV3-robots,代码行数:11,代码来源:Hello.java

示例5: LineFollower01

public LineFollower01() {
	mA = new EV3LargeRegulatedMotor(MotorPort.A);
	mB = new EV3LargeRegulatedMotor(MotorPort.B);
	mC = new EV3LargeRegulatedMotor(MotorPort.C);
	mB.setSpeed(120);// 2 RPM
	mC.setSpeed(120);
	mB.synchronizeWith(new RegulatedMotor[] { mC });
	color = colorSensor.getRGBMode();
	colorSample = new float[color.sampleSize()];
	touch = touchSensor.getTouchMode();
	sample = new float[touch.sampleSize()];
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:12,代码来源:LineFollower01.java

示例6: instantiateMotorCannon

/**
 * Instantiates the cannon-motor, optionally skips calibration
 * @param skipMotorCannonCalibration
 * @return
 */
private EV3MediumRegulatedMotor instantiateMotorCannon(
    boolean skipMotorCannonCalibration) {
  if (!skipMotorCannonCalibration) {
    calibrateMotorCannon();
  }
  EV3MediumRegulatedMotor motor = new EV3MediumRegulatedMotor(MotorPort.C);
  if (!skipMotorCannonCalibration) {
    motor.rotate(-360);
  }
  return motor;
}
 
开发者ID:magnusbae,项目名称:HelloBrick,代码行数:16,代码来源:EV3Helper.java

示例7: getMotorPort

private static Port getMotorPort(String p) throws EV3ScriptException {
  if (p != null) {
    switch (p) {
    case EV3Constants.A:
      return MotorPort.A;
    case EV3Constants.B:
      return MotorPort.B;
    case EV3Constants.C:
      return MotorPort.C;
    case EV3Constants.D:
      return MotorPort.D;
    }
  }
  throw new EV3ScriptException(EV3ScriptException.INVALID_MOTOR_PORT, MapBuilder.buildHashMap("port", p).build());
}
 
开发者ID:jbenech,项目名称:gnikrap,代码行数:15,代码来源:SimpleEV3Brick.java

示例8: 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


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