• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SensorPort类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中lejos.nxt.SensorPort的典型用法代码示例。如果您正苦于以下问题:Java SensorPort类的具体用法?Java SensorPort怎么用?Java SensorPort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: run

import lejos.nxt.SensorPort; //导入依赖的package包/类
@Override
public void run(){
	CompassSensor C = new CompassSensor(SensorPort.S4);
	while(!Button.ESCAPE.isPressed()){
		LCD.clear();
		if (DE!=null && DE.CN !=null){
			//DE.CN.updatePosition();
			LCD.drawString("A: " + String.valueOf(DE.CN.getAngle()), 1, 1);
			LCD.drawString("X: " + String.valueOf(DE.CN.getX()), 1, 2);
			LCD.drawString("Y: " + String.valueOf(DE.CN.getY()), 1, 3);
			LCD.drawString("C: " + String.valueOf(C.getDegrees()), 1, 4);
		}
		LCD.refresh();
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {;
		}
	}
}
 
开发者ID:PeterOrneholm,项目名称:penemunxt,代码行数:20,代码来源:NavigatorTest.java


示例2: identifySensorTypeFromName

import lejos.nxt.SensorPort; //导入依赖的package包/类
public static Sensor identifySensorTypeFromName(String selectedType, SensorPort port) {
    if (selectedType.equals(LegoTouchSensor.NAME)) {
        return new LegoTouchSensor(port);
    } else if (selectedType.equals(LegoLightSensor.NAME)) {
        return LegoLightSensor.getInstance(port);
    } else if (selectedType.equals(LegoSoundSensor.NAME)) {
        return new LegoSoundSensor(port);
    } else if (selectedType.equals(LegoUltrasonicSensor.NAME)) {
        return new LegoUltrasonicSensor(port);
    } else if (selectedType.equals(LegoColorSensor.NAME)) {
        return new LegoColorSensor(port);
    } else if (selectedType.equals(HTIRSeekerV2.NAME)) {
        return new HTIRSeekerV2(port);
    }            else {
        return null;
    }
}
 
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:18,代码来源:TypeConverter.java


示例3: WallDiscoverer

import lejos.nxt.SensorPort; //导入依赖的package包/类
public WallDiscoverer (Position robot, Movement move, Grid grid) {
	this.front = new UltrasonicSensor(SensorPort.S2);
	this.back = new UltrasonicSensor(SensorPort.S1);
	this.front.continuous();
	this.back.continuous();
	this.isInFrontPosition = false;
	
	this.robotPosition = robot;
	this.previousDistances = new int[4];
	this.previous = new Point(-1, -1);
	this.grid = grid;
	
	this.tmpDists = new int[5];
	this.movement = move;
}
 
开发者ID:yoann-dufresne,项目名称:AFIA_Robots,代码行数:16,代码来源:WallDiscoverer.java


示例4: WallDetector

import lejos.nxt.SensorPort; //导入依赖的package包/类
public WallDetector(Position pos) {
	this.pos = pos;
	this.front = new UltrasonicSensor(SensorPort.S2);
	this.front.continuous();
	this.isInFrontPosition = true;
	this.changeHeadPosition();
	this.distance= 255;
	this.stopped = false;
}
 
开发者ID:yoann-dufresne,项目名称:AFIA_Robots,代码行数:10,代码来源:WallDetector.java


示例5: run

import lejos.nxt.SensorPort; //导入依赖的package包/类
@Override
public void run() {
	int Tolerance = 5;
	int HeadFor;
	CompassSensor sensor = new CompassSensor(SensorPort.S1);
	Motor.A.setSpeed(5);
	sensor.resetCartesianZero();
	
	HeadFor = (int) sensor.getDegreesCartesian();

	while(!Button.ESCAPE.isPressed()) {
		LCD.drawInt((int) HeadFor, 1, 1);
		LCD.drawInt((int) Motor.A.getTachoCount(), 1, 2);
		LCD.drawInt((int) sensor.getDegreesCartesian(), 1, 3);

		if(sensor.getDegreesCartesian() > (HeadFor + Tolerance)){
			LCD.drawInt(1, 1, 4);
			Motor.A.backward();
		}else if(sensor.getDegreesCartesian() < (HeadFor - Tolerance)){
			LCD.drawInt(2, 1, 4);
			Motor.A.forward();
		}else{
			Motor.A.stop();
			LCD.drawInt(0, 1, 4);
		}
		
		LCD.refresh();
		
		try {
			Thread.sleep(25);
		} catch (InterruptedException e) {
		}
		
		LCD.clear();
	}
	
}
 
开发者ID:PeterOrneholm,项目名称:penemunxt,代码行数:38,代码来源:CompassTest.java


示例6: main

import lejos.nxt.SensorPort; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException{
	TiltSensor TS = new TiltSensor(SensorPort.S3);
	while (!Button.ESCAPE.isPressed()){
		LCD.drawInt(TS.getXAccel(), 2, 1);
		LCD.drawInt(TS.getYAccel(), 2, 2);
		LCD.drawInt(TS.getZAccel(), 2, 3);
		LCD.drawInt(TS.getXTilt(), 2, 4);
		LCD.drawInt(TS.getYTilt(), 2, 5);
		LCD.drawInt(TS.getZTilt(), 2, 6);
		try {
			Thread.sleep(500);
		} catch (InterruptedException e) {
		}
	}
}
 
开发者ID:PeterOrneholm,项目名称:penemunxt,代码行数:16,代码来源:TiltTest.java


示例7: init

import lejos.nxt.SensorPort; //导入依赖的package包/类
/** 
 *  
 * Initializes the robot machine, set ups the engines and sensors. 
 *  
 */ 
private static void init(){ 
     
    // get variables and sensors 
    sensor1 = new LightSensor(SensorPort.S1); 

    Motor.A.regulateSpeed(true); 
    Motor.B.regulateSpeed(true); 

    time_at_degree = (int) time_at_degree*(turningSpeed); 
}
 
开发者ID:xladde,项目名称:hsw,代码行数:16,代码来源:Linie.java


示例8: init

import lejos.nxt.SensorPort; //导入依赖的package包/类
private static void init() {
	// TODO Auto-generated method stub
	// Touchsensor, Lichtsensor instanzieren
	EXIT = new TouchSensor(SensorPort.S2);
	LIGHT = new LightSensor(SensorPort.S1);
	// Motoren zuweisen
	L = Motor.C;
	R = Motor.A;
	// letzte Richtung festlegen
	last_dir = DLEFT;
	// aktuelle Postion ermitteln und zuweisen
	last_pos = isOnLine() ? POS_BLACK : POS_WHITE;
}
 
开发者ID:xladde,项目名称:hsw,代码行数:14,代码来源:BigCourse.java


示例9: Control

import lejos.nxt.SensorPort; //导入依赖的package包/类
public Control(boolean sound) {
	this.sensorUltrasonico = new UltrasonicSensor(SensorPort.S2);
	this.sensorDelantero = new TouchSensor(SensorPort.S4);
	this.sensorTrasero = new TouchSensor(SensorPort.S1);

	this.sound=sound;
	
	Motor.B.setPower(this.potenciaMotor);
	Motor.C.setPower(this.potenciaMotor);
}
 
开发者ID:marianmoldovan,项目名称:atclegonxt,代码行数:11,代码来源:Control.java


示例10: NXTe

import lejos.nxt.SensorPort; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param port
 */
public NXTe(SensorPort port){
	super(port);
	
	port.setType(TYPE_LOWSPEED_9V);
	port.setMode(MODE_RAW);
	
	portConnected = port;
	
	arrLSC = new ArrayList<LSC>();
	
	this.setAddress((int) NXTE_ADDRESS);
	int I2C_Response;
	I2C_Response = this.sendData((int)this.REGISTER_IIC, (byte)0x0c);
}
 
开发者ID:marianmoldovan,项目名称:atclegonxt,代码行数:20,代码来源:NXTe.java


示例11: LDCMotor

import lejos.nxt.SensorPort; //导入依赖的package包/类
public LDCMotor(SensorPort port, int location, String DCMotorName, byte SPI_PORT,int forwardMinSpeed,int forwardMaxSpeed,int backwardMinSpeed, int backwardMaxSpeed){
	super(port,location,DCMotorName,SPI_PORT);
	
	this.forward_min_speed = forwardMinSpeed;
	this.forward_max_speed = forwardMaxSpeed;
	this.backward_min_speed = backwardMinSpeed;
	this.backward_max_speed = backwardMaxSpeed;
}
 
开发者ID:marianmoldovan,项目名称:atclegonxt,代码行数:9,代码来源:LDCMotor.java


示例12: PSPNXController

import lejos.nxt.SensorPort; //导入依赖的package包/类
public PSPNXController(SensorPort port)	{
	super(port);
	// Set correct sensor type, default is TYPE_LOWSPEED
	// port.setType(TYPE_LOWSPEED_9V);
	
	// Set proper mode (power on, etc..):
	powerUp(true);
	setDigitalMode(true);
}
 
开发者ID:marianmoldovan,项目名称:atclegonxt,代码行数:10,代码来源:PSPNXController.java


示例13: LMotor

import lejos.nxt.SensorPort; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param port the port
 * @param location the location 
 * @param name the name of the servo
 * @param SPI_PORT the SPI port
 *  
 */
public LMotor(SensorPort port, int location, String name, byte SPI_PORT){
	super(port);
	this.name = name;
	this.LSC_position = location;
	
	this.SPI_PORT = SPI_PORT;
	
	this.setAddress((int) NXTe.NXTE_ADDRESS);
}
 
开发者ID:marianmoldovan,项目名称:atclegonxt,代码行数:19,代码来源:LMotor.java


示例14: LSC

import lejos.nxt.SensorPort; //导入依赖的package包/类
/**
 * 
 * Constructor
 * 
 * @param port
 * @param SPI_PORT
 * 
 */
public LSC(SensorPort port,byte SPI_PORT){
	super(port);
	this.portConnected = port;
	this.SPI_PORT = SPI_PORT;
	
	arrServo = new ArrayList<LServo>();
	arrDCMotor = new ArrayList<LDCMotor>();
	
	this.setAddress((int) NXTe.NXTE_ADDRESS);
}
 
开发者ID:marianmoldovan,项目名称:atclegonxt,代码行数:19,代码来源:LSC.java


示例15: identifySensorPortFromName

import lejos.nxt.SensorPort; //导入依赖的package包/类
/**
 *
 * @param port either S1, S2, S3 or S4
 * @return the SensorPort corresponding to the NAME
 * @throws IllegalArgumentException if the NAME isn't one of the specified
 * names
 */
public static SensorPort identifySensorPortFromName(String port) {
    if (port.equals(Constants.S1)) {
        return SensorPort.S1;
    } else if (port.equals(Constants.S2)) {
        return SensorPort.S2;
    } else if (port.equals(Constants.S3)) {
        return SensorPort.S3;
    } else if (port.equals(Constants.S4)) {
        return SensorPort.S4;
    } else {
        throw new IllegalArgumentException("Sensor has to be either S1, S2, S3 or S4");
    }
}
 
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:21,代码来源:TypeConverter.java


示例16: identifySensorPortName

import lejos.nxt.SensorPort; //导入依赖的package包/类
public static String identifySensorPortName(SensorPort port) {
    if (port.equals(SensorPort.S1)) {
        return Constants.S1;
    } else if (port.equals(SensorPort.S2)) {
        return Constants.S2;
    } else if (port.equals(SensorPort.S3)) {
        return Constants.S3;
    } else if (port.equals(SensorPort.S4)) {
        return Constants.S4;
    } else {
        throw new IllegalArgumentException("Sensor has to be either S1, S2, S3 or S4");
    }
}
 
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:14,代码来源:TypeConverter.java


示例17: updateSensor

import lejos.nxt.SensorPort; //导入依赖的package包/类
private synchronized void updateSensor(Sensor toUpdate, int rawValue, String commonValue) {
    SensorPort port = toUpdate.getPort();
    int currentRow;
    if (port.equals(SensorPort.S1)) {
        currentRow = 0;
        if (sensorModel.getRowCount() >= currentRow) {
            sensorModel.removeRow(currentRow);
        }
        sensorModel.insertRow(currentRow, getSensorInfo(toUpdate,TypeConverter.identifySensorPortName(port), rawValue, commonValue));
    } else if (port.equals(SensorPort.S2)) {
        currentRow = 1;
        if (sensorModel.getRowCount() >= currentRow) {
            sensorModel.removeRow(currentRow);
        }
        sensorModel.insertRow(currentRow, getSensorInfo(toUpdate,TypeConverter.identifySensorPortName(port), rawValue, commonValue));
    } else if (port.equals(SensorPort.S3)) {
        currentRow = 2;
        if (sensorModel.getRowCount() >= currentRow) {
            sensorModel.removeRow(currentRow);
        }
        sensorModel.insertRow(currentRow, getSensorInfo(toUpdate,TypeConverter.identifySensorPortName(port), rawValue, commonValue));
    } else if (port.equals(SensorPort.S4)) {
        currentRow = 3;
        if (sensorModel.getRowCount() >= currentRow) {
            sensorModel.removeRow(currentRow);
        }
        sensorModel.insertRow(currentRow, getSensorInfo(toUpdate,TypeConverter.identifySensorPortName(port), rawValue, commonValue));
    }
}
 
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:30,代码来源:UI.java


示例18: actionPerformed

import lejos.nxt.SensorPort; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    modeBox.removeAllItems();
    modeBox.addItem(DEFAULT_MODE_BOX);
    String selectedSensor = (String) typeBox.getSelectedItem();
    String selectedPort = (String) sensorBox.getSelectedItem();
    SensorPort port = TypeConverter.identifySensorPortFromName(selectedPort);
    Sensor selected = TypeConverter.identifySensorTypeFromName(selectedSensor, port);
    List<String> modeList = selected.getModes();
    for (String mode : modeList) {
        modeBox.addItem(mode);
    }
}
 
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:14,代码来源:UI.java


示例19: getInstance

import lejos.nxt.SensorPort; //导入依赖的package包/类
public static LegoLightSensor getInstance(SensorPort port) {
    if (instances == null) {
        instances = new LegoLightSensor[4];//4 ports max
    }
    if (instances[port.getId()] == null) {
        instances[port.getId()] = new LegoLightSensor(port);
    }
    return instances[port.getId()];
}
 
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:10,代码来源:LegoLightSensor.java


示例20: LineDetectors

import lejos.nxt.SensorPort; //导入依赖的package包/类
public LineDetectors() {
	this.leftSensor = new ColorSensor(SensorPort.S4, Color.RED);
	this.rightSensor = new ColorSensor(SensorPort.S3, Color.RED);
	this.lastDetectLeft = this.lastDetectRight = 0;
	this.stopped = false;
}
 
开发者ID:yoann-dufresne,项目名称:AFIA_Robots,代码行数:7,代码来源:LineDetectors.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SQLJoinTableSource类代码示例发布时间:2022-05-23
下一篇:
Java ServerMUTube类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap