Skip to content

Commit 41d07b8

Browse files
committed
Adds updated method for changing address while commenting out older method
1 parent d5ecebc commit 41d07b8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

examples/Example3_ChangeAddress/Example3_ChangeAddress.ino

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ uint8_t deviceAddress = kQwiicUltrasonicDefaultAddress; // 0x2F
2828

2929
// New addres is 7-bit unshifted.
3030
uint8_t NEW_ADDR = 0x1E;
31+
//If using an older version of the Qwiic Ultrasonic, your address range is: 0x20 - 0x2F
32+
//uint8_t NEW_ADDR = 0x2F;
33+
3134

3235
void setup()
3336
{
@@ -54,9 +57,24 @@ void setup()
5457
Serial.print("Changing Address To: ");
5558
Serial.println(NEW_ADDR, HEX);
5659

60+
5761
// Call change address.....
58-
myUltrasonic.changeAddress(NEW_ADDR);
62+
sfeTkError_t err = myUltrasonic.updateAddress(NEW_ADDR);
63+
// If you have an older version of the Qwiic Ultrasonic, you'll need to use the following:
64+
//sfeTkError_t err = myUltrasonic.changeAddress(NEW_ADDR);
65+
66+
if(err)
67+
{
68+
while(1)
69+
{
70+
Serial.print("Error changing address: ");
71+
Serial.println(err);
72+
delay(1000);
73+
}
74+
}
5975
delay(1000);
76+
77+
// I
6078

6179

6280
Serial.print("Load up example 1 with the new address at: ");

0 commit comments

Comments
 (0)