Page 1 of 1
BitRead Function
Posted: Sun Jun 08, 2014 9:44 pm
by outlawstc
Arduinos program has A bitread function..
How do you perform this task in flowcode?
http://arduino.cc/en/Reference/BitRead
Re: BitRead Function
Posted: Sun Jun 08, 2014 9:52 pm
by medelec35
Re: BitRead Function
Posted: Sun Jun 08, 2014 10:06 pm
by outlawstc
I brought this over to there topic just to make it simple on others who may seek the same answer.. Thanks again medelec35
medelec35 wrote:For my 2 pence worth.
How I check is a bit is set or clear:
(Variable & (1 << bit)) <> 0 // to Check if bit of variable is set
or
(Variable & (1 << bit)) = 0 // to Check if bit of variable is Clear
So if you want to see if bit 2 is Clear:
If (Variable & (1 << 2)) = 0 then it's clear
If you want to see if bit 2 is Set:
If (Variable & (1 << 2)) <> 0 then it's set
Also if you want to set a bit:
Variable = Variable |(1<<bit)
To clear a bit:
Variable = Variables &~(1<<bit)
Martin