diff options
author | Federico Fissore <f.fissore@arduino.cc> | 2015-07-06 15:18:33 +0200 |
---|---|---|
committer | Federico Fissore <f.fissore@arduino.cc> | 2015-07-06 15:19:05 +0200 |
commit | b5a130afb51c971fd7ceca8834b6055f1eada253 (patch) | |
tree | d1e964f67822e9b3f10382573a9579c85b9c3e3f /libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino | |
parent | c13cf02651e178ea7941a82bee364d82c6b19b9c (diff) |
Examples: mass code format. See example_formatter.conf
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 |