I know with the LCD Display you can switch between codes, but I was wondering could the same thing be done with a Joystick’s buttons? Could I have one code set on 7U and press say 7D to switch to another code? If so how would the coding setup look like?
Well the issue with this is that your controller is disabled during autonomous but it would actually be pretty simple to code.
Here is some code for how to do it in robotC. The easyC code would be almost identical. Which do you use?
int choice;
if(button1==1){
choice=1;
}
if(button2==1){
choice=2;
}
if(button3==1){
choice=3;
}
if (choice==1)
{stuff }
if(choice==2)
{more stuff}
if (choice==3)
{more more stuff}
You would just need to choose auton before you plug into field control.
I’m not sure if you are set on using the controller or you are just using an alternative to an LCD screen you already have but I have found several other ways to do multiple autonomous if you are interested. What I did is, I made a selector switch with a potentiometer. I have ranges in my code that basically say if the potentiometer has a value in range x-y, the computer should run a certain code. I have seven of these said brackets making it possible for me to have seven programs based on where the potentiometer is turned. It’s actually really easy to program and is a quick fix if you don’t want to purchase an LCD screen. You can also do it with bumper switches or limit switches depending on what you have.
I can send you pictures of my program and can also send you pictures of the selector switch I found that allows me to choose between the seven programs if you would like. I can also send you my entire EasyC file if you are using EasyC. Good luck.
I’ve seen the selector switch created by Buy_n_large and it is pretty cool, quite a bit better than others I’ve seen.
Haha, I have sharpie marks on the pot.
Thank you Mr. Pearman!
That is always an option as well haha.
As a side comment, I just found a picture and can load it either to a post here or to the forum gallery if you would like Gizmotist. Let me know.
Im using RobotC and i wont have access to using a lcd screen so that is y i was thinking i might use a remote controller to do so. My robot isnt autonomous, it will only be controlled by a remote controller.
Thanks for your offer of help big_n_large, but sadly my robot isnt autonomous.
My objective is to have one set as fast speed and then another for precision
One simple way to do this would be to simply add a variable and an if / else if statement in your code. For example:
task main()
{
const int SPEED = 0;
const int PRECISION = 1;
int controlMode = SPEED;
while(true)
{
// control mode buttons
if(vexRT[Btn7U] > 0)
controlMode = SPEED;
else if(vexRT[Btn7D] > 0)
controlMode = PRECISION;
// joystick control code
if(controlMode == SPEED)
{
// place your "fast speed mode" code here
}
else if(controlMode == PRECISION)
{
// place your "precision mode" code here
}
}
}
Thank you that template was exactly what i needed. Got my 2 different codes running flawlessly. I will be adding “Credit due to user LegoMindstormsmaniac @ Vexforums for template” to my coding for credit.
Dang low level high school education on Vex coding.
@tabor473 and buy_n_large
Thanks for your taking some time to try and help.
for your autonomous mode use the competition template. as for the coding use
while(autonomous)
{
motor[port1]=127;
motor[port10]=127;
wait1Msec(2000);
motor[port1]=-127;
motor[port10]=127;
wait1Msec(2000);
}