How to extract a single bit from a byte variable.
tore eilertsen
Posts: 15
Hi
Im using the philips PCF8574 as a port expander for a bs2p on i2c.
Question..
the variable returned from the chip, inbyte is defined as byte, how can I scan true the 8 bits of inbyte and
determine which is 0 and which is 1, and take an action if say .. bit 4 is 1
can someone please help out with this problem ???
tore
Im using the philips PCF8574 as a port expander for a bs2p on i2c.
Question..
the variable returned from the chip, inbyte is defined as byte, how can I scan true the 8 bits of inbyte and
determine which is 0 and which is 1, and take an action if say .. bit 4 is 1
can someone please help out with this problem ???
tore
Comments
The two ways I can think of at the moment are:
1. Bit masking - Using the AND and OR functions
2. Use the NCD function
All of the above can be found in the PBASIC Reference Manual, and the PBASIC Help File.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OR
-Phil