Joined: 23 Sep 2003 Posts: 12 Location: South KOREA
what is Best coding?
Posted: Fri Feb 18, 2005 4:11 am
Dear Master.
Someone use
#bit A0 = porta.0
#define ON 1
if(A0 == ON)
another one use
if(input(pin_a0))
what is best code? _________________ Hello~?
This is South KOREA
My name is Sanghyouk Kim But Call me Nick
Sorry I'm poor English
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
hi again
Posted: Fri Feb 18, 2005 5:04 am
both look alright to me but if your using the CCS compiler I would use:
Code:
if(input(pin_a0));
you don't need to redefine a bit to represent pin_a0 because its already done just use pin_a0 to mean that pin. You also don't ned to do a comparison because the pin evaluates to 1 or 0 ie True or False which is already the result your looking for in an if() statement. I think the CCS manual talks about this somewhere try and look in that. I think my code might compile more efficient as well.
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