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

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -