Skip to content

Commit 12783af

Browse files
committed
fix: updating central device code
1 parent 2455425 commit 12783af

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

content/hardware/03.nano/boards/nano-rp2040-connect/tutorials/rp2040-ble-device-to-device/rp2040-ble-device-to-device.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ tags:
1010
- LED
1111
author: 'Karl Söderby'
1212
libraries:
13-
- name: Arduino LSM6DS3
14-
url: https://www.arduino.cc/en/Reference/ArduinoLSM6DS3
1513
- name: ArduinoBLE
1614
url: https://www.arduino.cc/en/Reference/ArduinoBLE
1715
hardware:
@@ -29,7 +27,7 @@ software:
2927

3028
In this tutorial, we will learn how to turn on the blue pixel onboard the Arduino® Nano RP2040 Connect board, from another board. For this, we will need two BLE compatible boards, such as the Nano RP2040 Connect board, where we will use the [ArduinoBLE](https://www.arduino.cc/en/Reference/ArduinoLSM6DS3) library to make the connection.
3129

32-
>**Note:** if you need help setting up your environment to use your Arduino Nano RP2040 board, please refer to [this installation guide](/software/ide-v1/installing-mbed-os-nano-boards).
30+
>**Note:** if you need help setting up your environment to use your Arduino Nano RP2040 board, please refer to [this installation guide](https://docs.arduino.cc/software/ide-v1/tutorials/getting-started/cores/arduino-mbed_nano).
3331
3432
## Goals
3533

@@ -156,13 +154,13 @@ Upload the code below to the central device.
156154
#include <ArduinoBLE.h>
157155
158156
void setup() {
159-
pinMode(LEDB, OUTPUT);
157+
pinMode(LED_BUILTIN, OUTPUT);
160158
Serial.begin(9600);
161159
while (!Serial);
162160
// initialize the BLE hardware
163161
BLE.begin();
164162
Serial.println("BLE Central - LED control");
165-
// start scanning for LED BLE peripherals
163+
// start scanning for Button Device BLE peripherals
166164
BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
167165
}
168166
void loop() {
@@ -177,9 +175,9 @@ void loop() {
177175
Serial.print("' ");
178176
Serial.print(peripheral.advertisedServiceUuid());
179177
Serial.println();
180-
if (peripheral.localName().indexOf("LED") < 0) {
181-
Serial.println("No 'LED' in name");
182-
return; // If the name doeshn't have "LED" in it then ignore it
178+
if (peripheral.localName().indexOf("Button Device") < 0) {
179+
Serial.println("No 'Button Device' in name");
180+
return; // If the name doesn't have "Button Device" in it then ignore it
183181
}
184182
// stop scanning
185183
BLE.stopScan();
@@ -221,10 +219,10 @@ void controlLed(BLEDevice peripheral) {
221219
//Serial.println(LEDCharacteristic.readValue(value));
222220
if (value == 0x01) {
223221
Serial.println("ON");
224-
digitalWrite(LEDB, HIGH);
222+
digitalWrite(LED_BUILTIN, HIGH);
225223
}
226224
else if (value == 0x00) {
227-
digitalWrite(LEDB, LOW);
225+
digitalWrite(LED_BUILTIN, LOW);
228226
Serial.println("OFF");
229227
}
230228
}

0 commit comments

Comments
 (0)