I have not been able to search out and answer in the list.
I have defines set to input pins. But when I try and test on those against int sized variables the results are not what I expect. Is my problem testing a bit against a byte even if the byte is a 1 or 0? Do I have to make a bit variable for testing? Am I being grossly ignorant?
#define Trig_source PIN_D0
int internal = 1;
if(Trig_source == internal)
run_internal();
When PIN_D0 is set high(simulated), the IF statement will never test true.
Thanks,
JIMc
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Wed Mar 24, 2004 3:51 pm
Use the input() function to read the pin. Then test the value
returned by that function.
Jim McBride
Joined: 24 Mar 2004 Posts: 21
Posted: Wed Mar 24, 2004 4:22 pm
OK will do. The #define seems to work fine for outputs. Not sure why I was expecting a variable to automatically grab an input from a port. wishful thinking...
Wanting to keep the code readable, the following works fine:
#define Trig_source PIN_D0
int internal = 1, external = 0;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum