Research
Go
Search
Contact
About Jab
Education
Research
Home
Contents
Go Back
RADAR BOT 1.2
RADAR_BOT.java
import lejos.nxt.*; import javax.microedition.lcdui.Graphics; public class RADAR_BOT { static int batteryLife; public static void credits(){ LCD.clear(); LCD.drawString("Juan Antonio",0,1); LCD.drawString("Brenha. Moral",0,2); LCD.drawString("juanantonio.info",0,3); LCD.refresh(); } public static void main(String [] options) throws Exception { batteryLife = Battery.getVoltageMilliVolt(); //Motor settings Motor.A.setSpeed(900); //Instances CompassSensor compassObj = new CompassSensor(SensorPort.S2); UltrasonicSensor usObj = new UltrasonicSensor(SensorPort.S1); Graphics gObj = new Graphics(); RADAR1_7 radarObj = new RADAR1_7(compassObj,usObj,Motor.A,gObj); //Store historical information about the enviroment where, Radar Bot operate radarObj.knowEnviroment(); Sound.playTone(50, 200); radarObj.moveToDegreeCero(); radarObj.showEnviroment(); boolean bl_detect; bl_detect = false; Motor.A.setSpeed(300); Motor.A.forward(); while(!Button.ESCAPE.isPressed()){ radarObj.detectChanges(); //Every 360 degrees, detect patterns if((int) compassObj.getDegreesCartesian()>= 355){ bl_detect = true; } if(bl_detect){ Sound.playTone(50, 200); bl_detect = false; radarObj.detectPattern(); } } Motor.A.stop(); Thread.sleep(5000); credits(); Thread.sleep(1000); } }
Top