Hi all!!
Is it possible to add 4 different command for 1 motor?
What I’m trying to do is to get 2 different power settings (back and forward) to the same motor.
I am programming on EasyC.
Please advise!
Thanks in advance!
Hi all!!
Is it possible to add 4 different command for 1 motor?
What I’m trying to do is to get 2 different power settings (back and forward) to the same motor.
I am programming on EasyC.
Please advise!
Thanks in advance!
I don’t use easyC, but if I get what your saying it would be something like this:
(pseudocode)
if(button to go forward is pressed)
{
motor = Full Power Forward
}
else if(button to go backwards is pressed)
{
motor = Full Power Backwards
}
// If you want the motor to stop if your not pressing any buttons:
else
{
motor = Stopped
}
Not exactly, that will be just a single button for a single command I guess,
I am trying something like this,
For Motor #6
Button 6 Up = 127
Button 6 Down = -127
Button 8 Up = 80
Button 8 Down = -80
I don’t know if this is more clear…
I am not sure what exactly what you mean, so here is my terrible way of explaining what I think you want.
If this is in Driver Mode:
If this is in Auton. Mode:
Hope this helps, ask if you need any new help. I can help if you give me more info.
So you want a single button to have multiple purposes in a sort of single button toggle?
Here is some somewhat modified code from one of the threads by @Oliver W :
bool buttonState;
int Button;
int prevButton;
while (true)
{
Button = VexRT[Btn5U];
// If you press the button and
// you were not previously pressing it
if(Button == 1 && prevButton == 0 )
{
// if the button state variable = 1
// do certain actions
if(buttonState == 1 )
{
motor = 127;
buttonState = 0;
}
// If the button state variable = 0
// doo another set of actions
else if(buttonState = 0)
{
motor = -127;
buttonState = 1;
}
}
prevButton = Button;
}
Making it for two buttons would require a few changes.
EDIT: While sitting here pondering what code could work, I came up with this example based off of Oliver’s Code:
bool buttonState, buttonState2;
int Button, Button2;
int prevButton, prevButton2;
while (true)
{
Button = VexRT[Btn5U];
Button2 = VexRT[Btn5D];
// If you press the button and
// you were not previously pressing it
if(Button == 1 && prevButton == 0 )
{
// if the button state variable = 1
// do certain actions
if(buttonState == 1 )
{
motor = 127;
buttonState = 0;
}
// If the button state variable = 0
// doo another set of actions
else if(buttonState = 0)
{
motor = -127;
buttonState = 1;
}
}
else if(Button2 == 1 && prevButton2 == 0 )
{
// if the button state variable = 1
// do certain actions
if(buttonState2 == 1 )
{
motor = 80;
buttonState2 = 0;
}
// If the button state variable = 0
// doo another set of actions
else if(buttonState2 = 0)
{
motor = -80;
buttonState2 = 1;
}
}
prevButton = Button;
prevButton2 = Button2;
}
Hopefully it, or something similar to it works