Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import lejos.hardware.port.SensorPort;
- import lejos.hardware.sensor.EV3ColorSensor;
- import lejos.hardware.sensor.EV3UltrasonicSensor;
- import lejos.robotics.SampleProvider;
- import Ressource.Robot20192020;
- public class mainRobot {
- //VARIABLE
- static EV3ColorSensor sensor4 = new EV3ColorSensor(SensorPort.S3);
- static SampleProvider light4= sensor4.getMode("Red");
- static float sample4[] = new float[light4.sampleSize()];
- static float x=(float) 0.2;
- //variable obstacle
- static EV3UltrasonicSensor sonar = new EV3UltrasonicSensor(SensorPort.S4);
- static float[] value = new float[1];
- static float y=(float) 0.9;
- public static void main(String[] args) {
- Robot20192020.AfficherUnmessage("READY STEP1");
- Robot20192020.Attendre(); // Le robot attend que l'on appuie pour avancer.
- step1();
- closeSensor();
- }
- public static void step1(){
- //boolean detection1 = false;
- while (x > 0.06 && x < 0.3 && y > 0.2) {
- light4.fetchSample(sample4, 0);
- x= sample4[0];
- Robot20192020.AfficherUnmessageinst("DETECTION:" +x);
- sonar.getDistanceMode().fetchSample(value, 0);
- y= value[0];
- Robot20192020.Avancer();
- }
- Robot20192020.Arreter();
- Robot20192020.FaireUnePause(2);
- Robot20192020.FaireUneRotationAGauche(180);
- }
- public static void closeSensor(){
- sensor4.close();
- sonar.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement