How to make a "shift key" in vexcode pro

void checkBattery () {
  if (Controller1.ButtonRight.pressing() && Controller1.ButtonY.pressing()) {


trying to make a shift key so i can tie maintenance functions to the buttons. whats wrong here? it doesnt work so.

Your issue may be that when you call the function you have to be holding both buttons. So the function works but you aren’t able to hold both buttons while the function activates. I would add a while loop to the function. Inside the while loop you have the if statement. So while the function activated it will loop through checking. You can also and that if statement to your driver control while loop instead. An easier solution may be to run the function when those buttons are pressed instead of running the function then pressing those buttons.


That’s the point. That you hold both buttons. I’m using all my buttons already

You’ve provided the function implementation but not how the function is called.

1 Like

Sorry. It’s running inside user control in a while loop. Ofc, all my normal drive code works + buttons, just the shift is broken.

Without seeing how it’s being called in context of the rest of your user control, it’s hard to offer anything constructive

1 Like

If that whole void is inside user control while loop, it will not do anything. If you put just that if statement in user control, it would work.

I have the function inside user control I.e. batterycheck();. The code format is literally jsut a while loop with all my code functions running and then a wait 20 mile seconds function. All my other code runs fine, its jsut that this specific one doesn’t run.

Since you seem unwilling to share your user control function, what happens if you comment out the if condition in the function?

EDIT - or what happens if you strip out the rest of your user control and only call this (with the if condition present)

Let’s say that A is your shift key and B is your button.

If (B is pressed) { if (A is pressed) {shift key thing} else {regular thing} }

I’m off of my computer. It’s in school. Sorry I can’t run 30 miles away to grab it. And yes I did try that.

And I’ll try that when I get to school on Monday.

Please don’t act insulted. You didn’t explain that, and it’s really hard to help without being able to read the entire code.

what worked for me was checking each button press in their own respective if statements

void checkBattery () 
   if (Controller1.ButtonRight.pressing()

We’re basically just waiting for him to go to school and send his code. Until then, we really don’t know what he did or didn’t do. @UvuvwevweOnyetenye You should upload your code to Google drive and share it with your mom or someone at home so it’s not only on your computer.

I have my class that I can code in (I just kinda take the laptop from the robotics room) in 40 minutes. I’ll do what you said since that’s actually smart. If you want to steal any aspects of my code for your own btw, I’d be happy to tell you what certain code does (since I don’t really comment my code well)

The V5 brain is a touchscreen, so you could also draw buttons on the screen during driver control or something so that when someone touches the button it prints the battery level. You could do something simple, like

while (touch is inside this position) {
  print Battery capacity to row 1 on the brain;

or something more complicated like, have one screen to touch the battery level button, and it takes you to another screen where it prints the battery level, and there’s an Exit button that takes you back to the main screen. Here is a site with a good explanation of switching between scenes. That would probably be more work than it’s worth, though.

Unless you’re like me and you enjoy it and have lots of free time. (I would guess not, since you have a limited amount of time with access to your computer.)

finally the moment youve all been waiting for

i had deleted the maintenance function previously, since i thought that it hurt performance, but it didnt work when i had it. dont worry im not that dumb lol. i made the code in like october or something

Sorry. I don’t have the V5 code app. I can’t open the file. Can you send a screenshot? Or it would be better if you copy and pasted it. You format code with ``` at the beginning and end. It comes out like this:

Brain.Screen.print("%d", Brain.Battery.capacity(percent));

So sorry. I should have told you.

Ok. Since I’m out of the class now I’ll have to do it at 230.