-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGyroDemo.java
More file actions
40 lines (29 loc) · 943 Bytes
/
Copy pathGyroDemo.java
File metadata and controls
40 lines (29 loc) · 943 Bytes
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
package ev3.exercises;
import ev3.exercises.library.*;
import lejos.hardware.Button;
import lejos.hardware.Sound;
import lejos.hardware.motor.*;
import lejos.hardware.port.*;
import lejos.utility.Delay;
public class GyroDemo
{
public static void main(String[] args)
{
GyroSensor gyro = new GyroSensor(SensorPort.S2);
System.out.println("Gyro Demo");
System.out.println("Press to start");
Button.LEDPattern(4); // flash green led and
Sound.beepSequenceUp(); // make sound when ready.
Button.waitForAnyPress();
// run until escape button pressed.
while (Button.ESCAPE.isUp())
{
Lcd.clear(5);
Lcd.print(5, "angle=%d av=%.3f", gyro.getAngle(), gyro.getAngularVelocity());
Delay.msDelay(250);
}
// free up resources.
gyro.close();
Sound.beepSequence(); // we are done.
}
}