i have tried a few things to get it to work but i just need to start over and go from scratch
if you can help me i need two motors to spin forward while the R1 button is held down when released they stop
i have tried a few things to get it to work but i just need to start over and go from scratch
if you can help me i need two motors to spin forward while the R1 button is held down when released they stop
Just some pseudocode, I’m sure you can figure out the actual commands after a quick search on the API:
if(Controller button is pressing){
Spin intakes
}
else{
Stop intakes
}
is there any way to do it with the name of the motor (intake1 and 2)
This is for the intakes to move forward, It creates a loop that is constantly checking if the specific button is being pressed, and if it is, it will carry out the action that is in the brackets.
if(Controller1. buttonR1.pressing){
spin.(intake1, 100, pct);
spin.(intake2, 100, pct);
}
else{
(stop::intake1);
(stop::intake2);
}
This is the code to make them go reversed, it is just on a separate button and the speed values are reversed.
if(Controller1. buttonR2.pressing){
spin.(intake1, -100, pct);
spin.(intake2, -100, pct);
}
else{
(stop::intake1);
(stop::intake2);
}
hope this helps!
thank you so much your a life saver
I think that the stop is right, if it is not, try
stop.(intake1)
the bolded code is highlighted red in the program
i guess something’s wrong don’t know what
if(Controller1.ButtonR1.pressing){
spin.(intake1, 100, pct);
spin.(intake2, 100, pct);
}
else{
(stop::intake1);
(stop::intake2);
}
Well you see, that seems like pseudocode. It isn’t the actual code, but it contains the logic within the code. You think through it and think about what motors you would need to start and stop.
I don’t know what the actual vex v5 api looks like so i could be wrong, but it seems weird to have an object named ‘spin’.
oh ok
i have seen a bunch of stuff say pseudocode, what does it mean?
You have to look at some sort of documentation, which says what functions do what.
spin is right, it is odd though. And I was just going off hte top of my head, so the stop is most likely wrong
what does the pct mean does that mean percent?
Taken directly from the Vex Api linked and mentioned above,
you have three options when it comes to velocity. I don’t think anyone really uses dps because it is the same as rpm essentially,
sorry, I screwed up the code. this is correct I think
(maybe)
if(Controller1. buttonR2.pressing()){
spin.(intake1, 100, pct);
spin.(intake2, 100, pct);
}
else{
intake1.stop(vex::brakeType::hold);
intake2.stop(vex::brakeType::hold);
}
Vexcode also has a thing where you can get exact pieces of text that are right. Just look for the ones that look like they should do the same thing as what I have put here.
That’s not the correct syntax for vexcode. To spin a motor, you say something like:
Motor.spin( fwd, 100, pct );
To stop a motor, you say:
Motor.stop();
I recommend you check out the API: VCS API Reference
(This is the VCS API, which is basically the same as Vexcode. There might be a newer version of this though, I’m not sure)
Hope this helps
totally screwed that one up, didn’t I?
this is right. I can’t believe I messed it up that bad. Sorry @glazebaize
where it says mars, you would put your controller name.
Thanks so much I will use this asap