Quote:
Originally Posted by drewjones13
if (rc_dig_in10 == 1)
{
cmd0; //Call the cmd0(forward) subroutine
}
[/code]
Subroutine
Code:
unsigned char cmd0()
{
pwm01 = pwm02 = 190; //Forward Half Speed
return 0;
}
|
What I think your problem is that you have nothing telling it how far to go. You may also not want to directly call the subroutine from the sensor do something to the sort of.
if (rc_dig_in10 == 1)
{
ButtonPressed = TRUE;
}
[/code]
Subroutine[code]
if (ButtonPressed == TRUE)
{
//You could also call your subroutine here if you wanted to
pwm01 = pwm02 = 190; //Forward Half Speed
return 0;
}
This will work because the way you had it written, as soon as the button lets go, it equals 0. Since the processor runs every 27 milliseconds or so, it will start, and then quickly stop if pressed once. Doing it the way I showed sets another variable that once it sees the button gets set, and if it gets let go it is still going. If you have anymore questions, let me know.
Joey
PS I'm not sure if the syntax is perfect, I just wanted to show you the concept.