// RunMonitor.java // // A main program to illustrate the monitor on the robot. // Based on the original code by Simon Parsons & Davide Grossi, 2013. // // Terry Payne // 6th October 2017 // // The keys on the brick provide simple motor control. // Note that the distance sensor motor is not used. import lejos.hardware.Button; import lejos.hardware.Keys; public class RunMonitor { public static void main(String[] args) throws Exception{ // Turn on the motors and monitor the robot until a button is pressed. SimpleRobot me = new SimpleRobot(); RobotMonitor myMonitor = new RobotMonitor(me, 400); myMonitor.start(); int keyPressed = Button.getButtons(); // Print a message on the screen and wait for one of the button presses while (Button.getButtons() != Keys.ID_ESCAPE) { switch (keyPressed) { case Keys.ID_UP: me.startMotors(); break; case Keys.ID_LEFT: me.turnMotors(false); break; case Keys.ID_RIGHT: me.turnMotors(true); break; case Keys.ID_ENTER: me.stopMotors(); break; case Keys.ID_DOWN: me.reverseMotors(); break; default: break; } Button.waitForAnyPress(); keyPressed = Button.getButtons(); } Button.waitForAnyPress(); me.closeRobot(); } }