Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.firstinspires.ftc.teamcode;
- import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cColorSensor;
- import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
- /**
- * Created by Ori on 02/02/2017.
- */
- public class beacone_detected_blue extends LinearOpMode{
- private HardWare11226 m_hardware = new HardWare11226();
- private boolean ranonce = false;
- @Override
- public void runOpMode() throws InterruptedException {
- m_hardware.init(hardwareMap);
- waitForStart();
- while (opModeIsActive() && !ranonce)
- {
- beaconDetect();
- ranonce = true;
- }
- }
- private int counter = 0 ;
- public void beaconDetect() {
- while (counter != 5 && counter != -5) {
- if (m_hardware.color_sensor.red() > m_hardware.color_sensor.blue() + 2) {
- counter--;
- } else if (m_hardware.color_sensor.blue() > m_hardware.color_sensor.red() + 2) {
- counter++;
- }
- idle();
- }
- if (counter == 5)
- {
- telemetry.addData("count", counter);
- telemetry.update();
- m_hardware.color_sensor.enableLed(true);
- } else if (counter == -5)
- {
- telemetry.addData("count", counter);
- telemetry.update();
- .enableLed(true);
- .enableLed(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement