9.7 Oprire robot după 3 secunde

//Retinem  timpul de start in variabila “start”

        long start = System.currentTimeMillis();

        motorStangaFata = hardwareMap.dcMotor.get(„motorStangaFata”);

        motorStangaSpate = hardwareMap.dcMotor.get(„motorStangaSpate”);

        motorDreaptaFata = hardwareMap.dcMotor.get(„motorDreaptaFata”);

        motorDreaptaSpate = hardwareMap.dcMotor.get(„motorDreaptaSpate”);

        waitForStart();

        //Atata timp cat opModeIsActive

        while (opModeIsActive()) {

            long final = System.currentTimeMillis();

            long timeElapsed = final – start;

            //In aplicatia FTC Driver Station se va afisa timpul scurs

            telemetry.addData(„timp scurs%d”,timeElapsed);

            telemetry.update();

            //Daca timpul scurs este mai mare decat 3 secunde(3000 milisecunde)

            //robotul se va deplase in fata, apoi va sta 2 secunde(2000 milisecunde)

            //si se va opri

            if(timeElapsed>3000) {

                motorStangaFata.setPower(-0.3);

                motorStangaSpate.setPower(-0.3);

                motorDreaptaFata.setPower(0.3);

                motorDreaptaSpate.setPower(0.3);

            sleep(2000);

            motorStangaFata.setPower(0);

            motorStangaSpate.setPower(0);

            motorDreaptaFata.setPower(0);

            motorDreaptaSpate.setPower(0);}

        }