Log in

View Full Version : HELP!!! STUCK WITH SUB ROUTINES WITH THE IR!!!


drewjones13
17-01-2008, 20:25
we are having issues with our IR coding in hybrid mode, below is what we have set up, for some reason its only running the first subroutine as if rc_dig_in10 is already initialized to "on" at the start of the code.

Auton Code:


time1 = time1 + 1;
if (time1 <= 5)
{
rc_dig_in10 = rc_dig_in11 = rc_dig_in12 = rc_dig_in13 = 0;
pwm01 = pwm02 = 127;
}
else if (rc_dig_in10 = 1)
{
cmd0();
}
else if (rc_dig_in11 = 1)
{
cmd1();
}
else if (rc_dig_in12 = 1)
{
cmd2();
}
else if (rc_dig_in13 = 1)
{
cmd3();
}
else
{
rc_dig_in10 = rc_dig_in11 = rc_dig_in12 = rc_dig_in13 = 0;
pwm01 = pwm02 = 127;
}

Subroutines:

unsigned char cmd0()
{
pwm01 = 190;
pwm02 = 190;
return 0;
}
unsigned char cmd1()
{
pwm01 = 64;
pwm02 = 64;
return 0;
}
unsigned char cmd2()
{
pwm01 = 190;
pwm02 = 64;
return 0;
}
unsigned char cmd3()
{
pwm01 = 64;
pwm02 = 190;
return 0;
}

psy_wombats
17-01-2008, 20:52
I believe the if statements are your problem. You're only using one equals sign. That will actually assign the bit the '1' rather than checking equivalence. You need to use the == operator instead.