Quote:
|
Originally Posted by MikeDubreuil
It's important to remember that in C "==" is a logical equal to operator and "=" is an assignment operator. "<=" is also a logical operator meaning less than or equal to. So I think you would want your code to look like this:
Code:
if (rc_dig_01 == 1) {
if (joy_1 <= 127) {
joy_1 = joy_1;
} else {
joy_1 = 127;
}
} else {
joy_1 = joy_1;
}
|
A good place for ternaries!
Full code might look like this:
Code:
if (RC_LIMITDOWN) //Alias to digital in
Joy_1 = ((Joy_1 < 127) ? 127 : Joy_1)
else if (RC_LIMITUP)
Joy_1 = ((Joy_1 > 127) ? 127 : Joy_1)