How to extract the LSB from a byte in C and Python? -
i'm sending byte raspi 3 , arduino via bluetooth serial.
e.g. 0b00000011 (mode), 0b01000001 (mode), 0b10010000 (direction)
the lsb indicates if byte direction command or instruction switch mode, need extract in arduino c , in python.
does know how this? in advance!
use bit operation:
c code
char b = 0x01; if( b & 0x01 ) { // lsb set } else { // lsb not set } python code
b = 0x01 if (b&0x01)==0x01 : # lsb set else: # lsb not set lsb = least significant bit (in case)
Comments
Post a Comment