I have PortA on an 18F8722 defined as an input port , and I want to read 3 of these pins at once. Say I want to read 0,3,5 and use the input in an IF statement is this possible?
I have PortA on an 18F8722 defined as an input port , and I want to read 3 of these pins at once. Say I want to read 0,3,5 and use the input in an IF statement is this possible?
You can check for a state on all 3 pins with one if statement if thats what you mean
In that example 0 and 3 must be high and 5 must be low to execute the code in the if statementCode:if porta.0=1 and porta.3=1 and porta.5=0 then endif
I know I can do it that way I was just looking to do it with out the and satements... so I can say something like:
Code:IF PortA135 = $6h then endif
That is also possible. You can use the bit AND operator (&).
The purpose of (porta & %00010101) is to strip out the unwanted information. Only the bit where you see a 1 will be kept from porta. Then you compare that with the value you are looking forCode:if (porta & %00010101)=%00010101 then
Edit: Looks like skimask got there before me!
I do a little morphing this time of year too.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2931&stc=1&d=122486118 8">
Dave
Always wear safety glasses while programming.
Is that going to be your new avatar for next week?
Thinking about it, i should get an avatar for halloween!
Your limited to 19.5K so that one is too big. Im sure someone here has an animated avatar already
Bookmarks