View Single Post
  #55   Spotlight this post!  
Unread 17-03-2004, 14:07
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: quick question: TIMERS

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:
Code:
if (rc_dig_in18)	{
That should take care of the problem you're having.