Double Press

I would like to know how to detect a double press invex code to be used to turn on intakes and then turn them off

1 Like

I believe the best way to do this is with a controller pressed event. Im still in school right now but when I get home I’ll try to make a tutorial for double presses when I have the time.


You could make it so pressing it once sets a variable to 1 and starts a timer and if it’s pressed again before the timer is out it does the command, if not it does the 1 press command


Basically what I’m trying to do is , if you hold down a trigger button it just spins the intakes until you let go, and if you double press then it runs either until you touch the button again, or tell it to go the other way. I want to do it to help out my team’s driver because I’ve noticed that they are having kind of a hard time holding down the intakes, and doing other stuff too.

Could you not just have a toggle run for the intake. A double press would be cool and all but I think you will get more use out of a simple toggle.

Maybe, I also think it would be cool to know how to do.


This will detect the number of clicks, as long as the clicks are within .2 seconds of each other. You can adjust it with the circled number.


I’m using vexCode text

Well, all of the logic is there for you to do it in text.


Yes I get that I just am not sure how to do a timer. I’m sure it’s simple I just know don’t know the syntax for it.

(Disclaimer, I don’t know much about programming with the new V5 stuff, I’ve been out of VEX for two years, but I still browse the forums and see if I can help)

Using the timer element from the C++ pro documentation:

It’s not very clear but it seems like vex::timer.time() returns the value of a timer initiatied with the program?

So maybe do something like

lastPress = 0
timeThreshold = 200 //ms
       if lastPress - vex::timer.time() < timeThreshold{
          //Do code here
       lastPress = vex::timer.time()

Again, I have no idea if that’s even formatted correctly, but you get the idea

Edit: It looks like the same thing can be done with vex::brain.timer()