本文整理汇总了Java中lejos.hardware.BrickFinder.getLocal方法的典型用法代码示例。如果您正苦于以下问题:Java BrickFinder.getLocal方法的具体用法?Java BrickFinder.getLocal怎么用?Java BrickFinder.getLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lejos.hardware.BrickFinder
的用法示例。
在下文中一共展示了BrickFinder.getLocal方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// File root = new File(".");
// String[] files = root.list();
// for(int i = 0; i < files.length; i++)
// lcd.drawString(files[i], 0, i);
Audio audio = ev3.getAudio();
audio.playSample(new File("hackathon.wav"), 100);
LCD.drawString("Enter to Exit", 0, 2);
Button.ENTER.waitForPressAndRelease();
// audio.playNote(Audio.XYLOPHONE, 420, 500);
// audio.playNote(Audio.XYLOPHONE, 510, 500);
// audio.playNote(Audio.XYLOPHONE, 420, 500);
// audio.playNote(Audio.XYLOPHONE, 640, 500);
// audio.playNote(Audio.XYLOPHONE, 220, 500);
// keys.waitForAnyPress();
}
示例2: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
Motor.B.setSpeed(720);// 2 RPM
Motor.C.setSpeed(720);
Motor.B.forward();
Motor.C.forward();
Delay.msDelay(1000);
Motor.B.stop();
Motor.C.stop();
Motor.B.rotateTo(360);
Motor.B.rotate(-720, true);
while (Motor.B.isMoving())
Thread.yield();
int angle = Motor.B.getTachoCount(); // should be -360
LCD.drawInt(angle, 0, 0);
keys.waitForAnyEvent();
}
示例3: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
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();
}
示例4: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
RegulatedMotor m = new EV3LargeRegulatedMotor(MotorPort.A);
m.resetTachoCount();
m.rotateTo(-40);
int angle = m.getTachoCount(); // should be 760
lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
// m.rotateTo(0);
// angle = m.getTachoCount(); // should be 0
// lcd.drawInt(angle, 0, 1);
// keys.waitForAnyPress(); // wait for a button press
m.close();
}
示例5: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
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);
}
示例6: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public static void main(String[] args) {
final EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// Color sensor
EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.S3);
SensorMode color = colorSensor.getRGBMode();
float[] colorSample = new float[color.sampleSize()];
lcd.drawInt(colorSample.length, 0, 2);
int key;
long startTime = System.currentTimeMillis();
long duration;
do {
duration = System.currentTimeMillis() - startTime;
color.fetchSample(colorSample, 0);
lcd.drawString("" + colorSample[0], 0, 3);
lcd.drawString("" + colorSample[1], 0, 4);
lcd.drawString("" + colorSample[2], 0, 5);
lcd.drawString("" + isReflecting(colorSample), 0, 6);
// key = keys.waitForAnyPress();
} while (duration < 60000);
}
示例7: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
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);
// Open clow
RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
while (true) {
mA.resetTachoCount();
lcd.drawString("Up - Close", 4, 2);
lcd.drawString("Down - Open", 4, 3);
lcd.drawString("Escape - Exit", 4, 4);
// Simple menu
keys.waitForAnyPress(60000);
int maRotation = 0;
if (Button.DOWN.isDown()) {
maRotation = -620;
} else if (Button.UP.isDown()) {
maRotation = 620;
}
if (Button.ESCAPE.isDown()) {
System.exit(0);
}
mA.rotateTo(maRotation, false);
int count = mA.getTachoCount();
lcd.drawString("Tacho: " + count, 0, 2);
}
}
示例8: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
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);
keys.waitForAnyPress(50000);
}
示例9: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
Audio audio = ev3.getAudio();
audio.setVolume(10);
audio.playNote(Audio.XYLOPHONE, 420, 500);
audio.playNote(Audio.XYLOPHONE, 510, 500);
audio.playNote(Audio.XYLOPHONE, 420, 500);
audio.playNote(Audio.XYLOPHONE, 640, 500);
audio.playNote(Audio.XYLOPHONE, 220, 500);
}
示例10: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
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();
}
示例11: main
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.S3);
SensorMode color = colorSensor.getColorIDMode();
float[] sample = new float[color.sampleSize()];
color.fetchSample(sample, 0);
int colorId = (int)sample[0];
String colorName = "";
switch(colorId){
case Color.NONE: colorName = "NONE"; break;
case Color.BLACK: colorName = "BLACK"; break;
case Color.BLUE: colorName = "BLUE"; break;
case Color.GREEN: colorName = "GREEN"; break;
case Color.YELLOW: colorName = "YELLOW"; break;
case Color.RED: colorName = "RED"; break;
case Color.WHITE: colorName = "WHITE"; break;
case Color.BROWN: colorName = "BROWN"; break;
}
lcd.drawString(colorId + " - " + colorName, 0, 0);
keys.waitForAnyPress();
// 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();
}
示例12: SimpleEV3Brick
import lejos.hardware.BrickFinder; //导入方法依赖的package包/类
public SimpleEV3Brick() {
BrickFinder.getLocal();
}