OSDN Git Service

lejos_NXJ_win32_0_5_0beta.zip
[nxt-jsp/lejos_nxj.git] / nxtOSEK / lejos_nxj / samples / TiltTest / TiltTest.java
1
2 import lejos.nxt.*;
3
4 /**
5  * Simple test of Acceleration (Tilt) sensors.
6  * 
7  * This should work with Mindsensors and HiTechnic Acceleration
8  * sensors.
9  * 
10  * @author Lawrie Griffiths
11  *
12  */
13 public class TiltTest {
14         
15         public static void main(String[] args) throws Exception {
16                 TiltSensor tilt = new TiltSensor(SensorPort.S1);
17                         
18                 while(!Button.ESCAPE.isPressed()) {
19                         LCD.clear();
20                         LCD.drawInt(tilt.getXTilt(), 6, 0, 0);
21                         LCD.drawInt(tilt.getYTilt(), 6, 0, 1);
22                         LCD.drawInt(tilt.getZTilt(), 6, 0, 2);
23                         LCD.drawInt(tilt.getXAccel(), 6, 0, 3);
24                         LCD.drawInt(tilt.getYAccel(), 6, 0, 4);
25                         LCD.drawInt(tilt.getZAccel(), 6, 0, 5);
26                         LCD.refresh();
27                         Thread.sleep(500);
28                 }
29         }       
30 }