Pressed In C++

Hello. We are currently trying to used pressed instead of pressing. The reason is when we do a pressing, it will not allow the robot to move. We tried to do the pressed command but it errored. Any help will be appreciated.

You need a call back function

We don’t understand. This is our first year as a club, team, and programmer. Is there a sample code or a How to on youtube?

So if I understand what you are trying to do you are trying to make a puncher shoot with the press of a button. However, the button pressed function activates a function(you can not use it as a condition in a if statement.) Basically, make a function called shootball that shoots the ball, then in the usercontrol loop, just put shootball in the button pressed parameter.

Your function should look like this:

   void shootball()
         PUNCHER.setVelocity(100, velocityUnits::pct);

Then in your usercontrol loop put this:

Just make sure you only call that once, don’t put it inside the while loop, best to put it near the beginning of main.

1 Like