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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -