Are 0b11111100 and 0b00000010 universal read and write commands?

i am trying to modify the SPI-example code "BarometricPressureSensor" (SCP1000) implemented in the IDE 1.5.6-r2 to work on my BMA020- Acceleration Sensor.

( )

Tom Igoe's code contains the following lines:

const byte READ = 0b11111100;     // SCP1000's read command
const byte WRITE = 0b00000010;   // SCP1000's write command

Due to the lack of reference in the SCP1000 data sheet and the unsatisfying results google presents me I have got two questions.

1. Is the Hex-Code universal,or does every sensor has an unique one?

  1. Supposed the coding is unique: How do I find the matching code for my sensor?

Thank you for your time,

  1. Not universal.
  2. Read your sensor's datasheet. Section 4 shows for SPI there is a control byte needed. For I2C there is an address and then a control byte needed. The control byte will vary with what you are trying to do.

No the codes are not unique. You look in the datasheet for the answers.


Those are binary numbers. 0b tells the compiler so.

10 is decimal for ten.
0b1010 is binary for ten, the same number written differently, in bits instead of digits.

x = 10;
y = 0b1010;

x and y hold the same value. x == y is true.

Thank you guys!

You are awesome!
I got stuck inside my own tunnel vision, searching for details without questioning my premise. Now I'm good to go again :wink: