I want to drive a motor using channel 5 or 6 switches.
In short, if I press channel 5 up, I want to go half speed forward and if I press channel 5 down, I want to go half speed reverse.
How can I do this using the Motor Module RX unit?
I want to drive a motor using channel 5 or 6 switches.
In short, if I press channel 5 up, I want to go half speed forward and if I press channel 5 down, I want to go half speed reverse.
How can I do this using the Motor Module RX unit?
Yes, you would use “Get RXInput” and map the output to a variable. Then you could create an “if” statement that runs when a button is pushed. Then you would specify the motor(s) speed and direction in the if statement. When nothing is being pushed you would turn off the motor(s).
We tried that using the SetMotor unit and things got real messed up. We lost coms with the transmitter and all motors started running at one time.
Is it possible to set a motor speed using the Motor Module RX unit?
A snippet of code would be quite enlightening.
We tried something like this:
unsigned char Chan_6;
Chan_6 = GetRxInput(1, 6); // Get Channel 6 input
SetMotor(4, 127); // Turn off motor 4 by default
if (Chan_6 > 150) {
SetMotor(4, 157); // Run the motor forward slowly
}
if (Chan_6 < 120) {
SetMotor(4,97); // Run the motor backwards slowly
}
Of course, this is all within a while loop.
Try This:
{
while ( 1 )
{
Chan_6 = GetRxInput ( 1 , 6 ) ;
if ( Chan_6 == 127 )
{
SetMotor ( 1 , 127 ) ;
}
else if ( Chan_6 == 0 )
{
SetMotor ( 1 , 0 ) ;
}
else if ( Chan_6 == 255 )
{
SetMotor ( 1 , 255 ) ;
}
}
}