3 public class SpeedTest {
5 static final int TOTALTIME = 60000;
7 public static void main(String [] args) throws Exception {
9 LightSensor ls = new LightSensor(SensorPort.S3);
10 UltrasonicSensor us = new UltrasonicSensor(SensorPort.S1);
11 /* Disable the speed regulation and close down the associated threads.
12 * This test does not require this type of motion control.
14 Motor.A.regulateSpeed(false);
15 Motor.B.regulateSpeed(false);
16 Motor.C.regulateSpeed(false);
24 int startTime = (int)System.currentTimeMillis();
29 while(totalTime < TOTALTIME) {
30 lightVal = ls.readValue();
31 distVal = us.getDistance();
32 tacho = Motor.B.getTachoCount();
33 int RN = (int)(Math.random() * 100) + 1;
35 // Uncomment the following to produce display output as per the original test.
36 //LCD.drawInt(tacho,0,0);
37 //LCD.drawInt((lightVal + distVal + tacho)*100/RN, 0, 1);
38 //LCD.drawInt(A, 0, 2);
39 //LCD.drawInt(iteration, 0, 4);
42 // Set motor speed for B and C to RN (Using Coast)
49 if(A<0) Motor.A.backward(); else Motor.A.forward();
51 totalTime = (int)System.currentTimeMillis() - startTime;
54 LCD.drawInt(iteration, 0, 4);