Announcement

Collapse
No announcement yet.

How to turn on motor using butttons?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to turn on motor using butttons?

    I'm trying to turn on a motor for our sweeper using the y button on the controller, but it won't work. The code doesn't throw any errors, it's just that nothing happens when i press the y button. Right now, our code looks like this:

    if (gamepad1.y){
    robot.Sweeper_Motor.setPower(1.0);
    }
    else if (gamepad1.a){
    robot.Sweeper_Motor.setPower(0.0);
    }

    If anyone could help us, that'd be great!

  • #2
    That code snippet looks OK to me. I suspect the error is elsewhere; perhaps it's mechanical or electrical, or perhaps elsewhere in your code. Can you please post your whole op mode to somewhere like pastebin.com or Google Drive, etc?
    John McDonnell
    Co-Mentor, Team 5873
    https://www.facebook.com/Team5873

    Comment


    • #3
      Is the switch on the bottom of the gamepad in the X position?

      Did you press "Start-A" before trying it to activate gamepad1?

      Comment


      • #4
        Problem found possible

        Originally posted by jockynerd10094 View Post
        I'm trying to turn on a motor for our sweeper using the y button on the controller, but it won't work. The code doesn't throw any errors, it's just that nothing happens when i press the y button. Right now, our code looks like this:

        if (gamepad1.y){
        robot.Sweeper_Motor.setPower(1.0);
        }
        else if (gamepad1.a){
        robot.Sweeper_Motor.setPower(0.0);
        }

        If anyone could help us, that'd be great!
        If you are using the normal ftc sdk, you can probably just do

        if (gamepad1.y){
        Sweeper_Motor.setPower(1.0);
        }
        else if (gamepad1.a){
        Sweeper_Motor.setPower(0.0);
        }
        diffrence: I took out the work robot in front of the motor name
        Hope this works

        Comment

        Working...
        X