我正在通过蓝牙串行向我的 Raspi 3 和 Arduino 发送一个字节。
例如0b00000011
(模式),0b01000001
(模式),0b10010000
(方向)
LSB 指示该字节是方向命令还是切换模式的指令,因此我需要在 Arduino C 和 Python 中提取它。
有人知道该怎么做吗? 提前致谢!
最佳答案
使用位运算:
C代码
char b = 0x01;
if( b & 0x01 ) {
// LSB is set
}
else {
// LSB is not set
}
Python代码
b = 0x01
if (b&0x01)==0x01 :
# LSB is set
else:
# LSB is not set
LSB = L东S重要B它(在您的情况下)
关于python - 如何在 C 和 Python 中从字节中提取 LSB?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43286860/