Skip to content

Commit 7dcc074

Browse files
biagiomcalvinatintel
authored andcommitted
Update bus_scan.ino sketch of Wire library
Improve documentation, code formatting and use LED_BUILTIN instead of 13 to control the on-board led connected to digital pin 13 of Arduino/Genuino 101 Signed-off-by: Biagio Montaruli <[email protected]>
1 parent 23ca972 commit 7dcc074

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libraries/Wire/examples/bus_scan/bus_scan.ino

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <Wire.h>
1919

20-
byte startAddress = 1; // skip reserved address from 0 to 7
20+
byte startAddress = 1;
2121
byte endAddress = 127;
2222

2323
void I2CBusScan(byte startAddress, byte endAddress)
@@ -36,20 +36,22 @@ void I2CBusScan(byte startAddress, byte endAddress)
3636
void setup()
3737
{
3838
// Initialize pin 13 as an output - onboard LED.
39-
pinMode(13, OUTPUT);
39+
pinMode(LED_BUILTIN, OUTPUT);
4040

4141
// join i2c bus (address optional for master)
4242
Wire.begin();
4343

44+
// initialize Serial communication
4445
Serial.begin(115200);
46+
// wait for the Serial port to connect. Open the Serial Monitor to continue executing the sketch
4547
while(!Serial);
4648
}
4749

4850
boolean toggle = false; // state of the LED
4951
void loop()
5052
{
5153
toggle = !toggle;
52-
digitalWrite(13, toggle);
54+
digitalWrite(LED_BUILTIN, toggle);
5355
delay(5000);
5456

5557
Serial.print("Start I2C Bus Scan from ");
@@ -58,7 +60,7 @@ void loop()
5860
Serial.print(endAddress);
5961
Serial.println(".....");
6062

61-
I2CBusScan( startAddress, endAddress);
63+
I2CBusScan(startAddress, endAddress);
6264

6365
Serial.println("\ndone");
6466
}

0 commit comments

Comments
 (0)