-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRemoteControl.java
More file actions
76 lines (62 loc) · 2 KB
/
RemoteControl.java
File metadata and controls
76 lines (62 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.rmi.RemoteException;
import lejos.hardware.BrickFinder;
import lejos.hardware.BrickInfo;
import lejos.hardware.Sound;
import lejos.hardware.ev3.EV3;
import lejos.hardware.lcd.GraphicsLCD;
import lejos.remote.ev3.RMIRegulatedMotor;
import lejos.remote.ev3.RemoteEV3;
import lejos.utility.Delay;
public class RemoteControl {
RemoteEV3 ev3 = null;
RMIRegulatedMotor motorA = null;
RMIRegulatedMotor motorB = null;
RMIRegulatedMotor motorC = null;
RMIRegulatedMotor motorD = null;
//FrontDorOpen
private boolean isOpen = false;
public boolean getIsOpen() { return isOpen; }
public static void main(String[] args) {
RemoteControl rc = new RemoteControl();
}
public RemoteControl(){
setup();
}
private void setup() {
try {
EV3 ev = (EV3) BrickFinder.getDefault();
BrickInfo[] bricks = BrickFinder.discover();
for(BrickInfo info: bricks) {
System.out.println("Ev3 found on Bluetooth ip: " + info.getIPAddress());
}
ev3 = new RemoteEV3(bricks[0].getIPAddress());
// ev3 = (RemoteEV3) BrickFinder.getDefault();
// EV3 ev = (EV3) BrickFinder.getDefault();
} catch (Exception e) {
e.printStackTrace();
}
ev3.setDefault();
GraphicsLCD display = ev3.getGraphicsLCD();
display.clear();
Sound.beep();
motorA = ev3.createRegulatedMotor("A",'l');
motorB = ev3.createRegulatedMotor("B",'l');
motorC = ev3.createRegulatedMotor("C",'l');
motorD = ev3.createRegulatedMotor("D",'l');
Sound.beep();
try {
// test the first motor
motorA.rotate(360);
} catch (RemoteException e) {
e.printStackTrace();
}
}
public boolean forward(int sek) throws RemoteException{
motorA.forward();
motorB.forward();
Delay.msDelay(sek*1000);
motorA.stop(false);
motorB.stop(false);
return false;
}
}