Skip to content

Instantly share code, notes, and snippets.

@ChrisStueber
Created January 5, 2018 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisStueber/33b27a472244d0831fda53313889e569 to your computer and use it in GitHub Desktop.
Save ChrisStueber/33b27a472244d0831fda53313889e569 to your computer and use it in GitHub Desktop.
EV3 erste Programme
import lejos.hardware.Button;
import lejos.hardware.ev3.LocalEV3;
import lejos.hardware.lcd.GraphicsLCD;
import lejos.hardware.motor.EV3LargeRegulatedMotor;
import lejos.hardware.port.MotorPort;
import lejos.robotics.RegulatedMotor;
import lejos.utility.Delay;
/**
* Benötigt ein Fahrzeug mit zwei unabhängigen Motoren Die Motoren müssen an
* Port B und C angeschlossen sein
*
* @author christoph.stueber@mes-alsfeld.eu
* @version 2018.01 erstellt 02.01.2018
*
*/
public class EV3Test
{
public static void main(String[] args)
{
// Ausgabe der Intro-Message auf dem LCD-Display des Bricks
GraphicsLCD g = LocalEV3.get().getGraphicsLCD();
g.drawString("Motor-Demo", 5, 0, 0);
g.drawString("Fährt ein Rechteck", 2, 20, 0);
g.drawString("Zwei unabhängige Motoren", 2, 30, 0);
g.drawString("an Port B und Port C", 2, 40, 0);
// Linker Motor an Port C
RegulatedMotor left = new EV3LargeRegulatedMotor(MotorPort.C);
// Rechter Motor an Port B
RegulatedMotor right = new EV3LargeRegulatedMotor(MotorPort.B);
// Und im Rechteck fahren
while (Button.ESCAPE.isUp())
{
// Geschwindigkeit (Grad pro Sekunde)
left.setSpeed(360);
right.setSpeed(360);
// Beide Motoren vorwärts
left.forward();
right.forward();
// Eine Sekunde fahren lassen
Delay.msDelay(1000);
// Beide Motoren stop
left.stop(true);
right.stop(true);
// Um 90 Grad rotieren
left.rotate(180, true);
right.rotate(-180, true);
while (right.isMoving())
{
Thread.yield();
}
}
left.close();
right.close();
}
}
import lejos.hardware.lcd.LCD;
import lejos.utility.Delay;
/**
* @author christoph.stueber@mes-alsfeld.eu
* @version 2018.01 erstellt 02.01.2018
*/
public class Hallo
{
/**
* @param args
*/
public static void main(String[] args)
{
LCD.drawString("Hallo hier ist EV3", 0, 4);
Delay.msDelay(5000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment