Announcement

Collapse
No announcement yet.

1 button positional servo programing.

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

  • 1 button positional servo programing.

    I am pretty new to blocks. I would like to know if the there is a way to use one button to make a servo move to a position with one press of the button and move back with another press.

  • #2
    blakee22 There is a tutorial (as part of the online Blocks Tutorial) that shows you how to do this:

    https://github.com/FIRST-Tech-Challe...Servo-(Blocks)

    I hope this helps. Let us know if you have any additional questions.

    Tom

    Comment


    • #3
      This video may be helpful.
       

      Comment


      • #4
        Thanks for the response I was just wondering if there was a way to use the same button for 2 positions

        Comment


        • #5
          Yes, create a variable and set it to 0 or 1 according to what position your robot's servo is in. Use it to decide what to do each time the button is pushed.

          Comment


          • #6
            The problem is that the SDK won't tell you "each time the button is pressed". It only tells you whether or not it is pressed, several times per second. So the behavior blakee22 wants is actually harder than has been suggested by the other posters. You have to use a variable to keep track of the state of the button as of the previous loop. Then you can write your if statement like this:

            If the button was NOT previously pressed AND is currently pressed, change the servo position (like schaferbw said, you can use the currently assigned servo position to decide which position to set the servo to).

            If those two conditions are not both met, you should ignore the fact that the button is currently pressed.

            BTW schaferbw, your video link didn't work.

            Comment


            • #7
              thanks I will try it out and see how it works

              Comment

              Working...
              X