This is an archive of G2M. Please refer to this post for more information. Archived on 2026-01-09.

Timer

Connor_91917B
01/18/2023 at 03:28:39 PM PST

Has anyone used a timer to stop the bot from expanding early, and if so how? We are using vexcode pro v5. We keep having problems with that.

7996B
01/18/2023 at 04:46:04 PM PST

Could you send the code you are using to try and do that? It will help us help you

Connor_91917B
01/18/2023 at 06:52:22 PM PST

Replying to 7996B ↩️

I can not send a photo currently, because I do not have the laptop with me, but basically, I have a function that tells my endgame pneumatics to extend, so it will launch my endgame string. What I am trying to do is add timer, that will make it so it will not launch even if I click the button, until the last 10 seconds of the match. If needed, I can still attach a photo tomorrow.

7996B
01/18/2023 at 07:10:39 PM PST

Replying to Connor_91917B ↩️

Ok, what you do is

  1. before the user control while loop is entered, check what the brain’s internal timer is at, save that value in a variable
  2. during the driver control loop, check to see if the internal timer is 1 min 35 sec more than the initial time
  3. if it is and you are pressing the button to launch endgame, then launch endgame

If this doesn’t help, let me know and feel free to ask questions, I’d prefer not to just give you the code, but i can give a more in depth step by step guide

Connor_91917B
01/19/2023 at 10:32:08 AM PST

Replying to 7996B ↩️

Do I have to clear the timer once before driver starts? Or will it clear itself once driver control starts.

calvc01
01/19/2023 at 11:26:05 AM PST

Replying to Connor_91917B ↩️

Clearing it would be easier, then it is the same base to work from every time. @7996B was suggesting taking the value at the start of Driver, then using that as the base. Both achieve the same thing, but resetting it is probably cleaner to read.

Connor_91917B
01/19/2023 at 02:01:17 PM PST

Replying to calvc01 ↩️

What I can not figure out how to do is make the timer reset once, when the user control period starts. I should be able to get the rest.

Connor_91917B
01/19/2023 at 02:47:11 PM PST

Replying to 7996B ↩️

I understand it for the most part. The part I am trying to figure out is how can I reset the timer right when user control starts. If I do that, I already have found how to get the value, and all of that.

Connor_91917B
01/19/2023 at 03:30:51 PM PST

Replying to 7996B ↩️

I was able to get it to work. Thank you for the help!