diff options
Diffstat (limited to 'libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino')
-rw-r--r-- | libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino index d97a9e3..4d0a68f 100644 --- a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino +++ b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino @@ -12,16 +12,14 @@ #include <Wire.h> -void setup() -{ +void setup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial communication at 9600bps } int reading = 0; -void loop() -{ +void loop() { // step 1: instruct sensor to read echoes Wire.beginTransmission(112); // transmit to device #112 (0x70) // the address specified in the datasheet is 224 (0xE0) @@ -44,8 +42,7 @@ void loop() Wire.requestFrom(112, 2); // request 2 bytes from slave device #112 // step 5: receive reading from sensor - if (2 <= Wire.available()) // if two bytes were received - { + if (2 <= Wire.available()) { // if two bytes were received reading = Wire.read(); // receive high byte (overwrites previous reading) reading = reading << 8; // shift high byte to be high 8 bits reading |= Wire.read(); // receive low byte as lower 8 bits |