Quote:
|
Originally Posted by Xufer
Code:
if (rc_dig_in18=1) {
when i do it like that reguardless of the switch it always works like the switch is on even when its off.
|
That's because you've fallen into a common trap with the c language's syntax. Testing for equality is done with the == "is equal" operator, and you've instead used the = "assignment" operator. Your code assigns the value "1" to the variable "rc_dig_in18", and then tests the result -- which is always 1, interpreted as
true by the software.
What your first line should say instead is this:
Code:
if (rc_dig_in18==1) {
Or you could leave off the explicit test for 1, and let c's boolean rules work for you:
That should take care of the problem you're having.