10000 More changes · ev3dev-lang-java/docs@21958b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21958b9

Browse files
committed
More changes
1 parent 19e7dbe commit 21958b9

File tree

86 files changed

+273
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+273
-124
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ev3dev.sensors;
2+
3+
import lejos.utility.Delay;
4+
5+
public class BatteryExample {
6+
7+
public static void main(String[] args) {
8+
9+
final Battery battery = Battery.getInstance();
10+
11+
for(int x = 0; x < 20; x++){
12+
System.out.println("Battery Voltage: " + battery.getVoltage());
13+
14+
Delay.msDelay(1000);
15+
}
16+
}
17+
18+
}

src/main/asciidoc/fundamentals/robot-architecture.adoc renamed to src/main/asciidoc/fundamentals/the-robot-architecture.adoc

Lines changed: 11 additions & 21 deletions

src/main/asciidoc/fundamentals/what-is-a-robot.adoc

Lines changed: 8 additions & 1 deletion
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
public class HelloWorld {
22

33
public static void main(String[] args) {
4-
// Prints "Hello, World" to the terminal window.
5-
System.out.println("Hello, World");
4+
// Prints "Hello World" to the terminal window.
5+
System.out.println("Hello World");
66
}
77

88
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package examples;
2+
3+
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
4+
import ev3dev.sensors.Battery;
5+
import lejos.hardware.port.MotorPort;
6+
import lejos.utility.Delay;
7+
8+
public class MyFirstRobot {
9+
10+
public static void main(final String[] args){
11+
12+
System.out.println("Creating Motor A & B");
13+
final EV3LargeRegulatedMotor motorLeft = new EV3LargeRegulatedMotor(MotorPort.A);
14+
final EV3LargeRegulatedMotor motorRight = new EV3LargeRegulatedMotor(MotorPort.B);
15+
16+
//To Stop the motor in case of pkill java for example
17+
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
18+
public void run() {
19+
System.out.println("Emergency Stop");
20+
motorLeft.stop();
21+
motorRight.stop();
22+
}
23+
}));
24+
25+
System.out.println("Defining the Stop mode");
26+
motorLeft.brake();
27+
motorRight.brake();
28+
29+
System.out.println("Defining motor speed");
30+
final int motorSpeed = 200;
31+
motorLeft.setSpeed(motorSpeed);
32+
motorRight.setSpeed(motorSpeed);
33+
34+
System.out.println("Go Forward with the motors");
35+
motorLeft.forward();
36+
motorRight.forward();
37+
38+
Delay.msDelay(2000);
39+
40+
System.out.println("Stop motors");
41+
motorLeft.stop();
42+
motorRight.stop();
43+
44+
System.out.println("Go Backward with the motors");
45+
motorLeft.backward();
46+
motorRight.backward();
47+
48+
Delay.msDelay(2000);
49+
50+
System.out.println("Stop motors");
51+
motorLeft.stop();
52+
motorRight.stop();
53+
54+
System.out.println("Checking Battery");
55+
System.out.println("Votage: " + Battery.getInstance().getVoltage());
56+
57+
System.exit(0);
58+
}
59+
}

src/main/asciidoc/getting_started/brick.adoc

Lines changed: 38 additions & 68 deletions

0 commit comments

Comments
 (0)
0