You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For this Bluetooth® Low Energy application example, we are going to control the Nano Matter built-in LED and read the onboard button status. The example sketch to be used can be found in **File > Examples > Silicon Labs > ble_blinky**:
835
837
@@ -1176,7 +1178,134 @@ Open the **Simplicity Connect** app on your smartphone, in the lower menu, navig
1176
1178
1177
1179

1178
1180
1179
-
***You can also manage the LED control and button status manually from the Scan tab in the lower menu.***
1181
+
### Arduino BLE
1182
+
1183
+
Now let's do the same but using the `ArduinoBLE` library.
1184
+
1185
+
In the upper menu, navigate to **Tools > Protocol stack** and select **BLE(Arduino)**.
For this Bluetooth® Low Energy application example, we are going to control the Nano Matter built-in LED and read the onboard button status, everything from the **Simplicity Connect** app.
1190
+
1191
+
```arduino
1192
+
#include <ArduinoBLE.h>
1193
+
1194
+
BLEService ledService("de8a5aac-a99b-c315-0c80-60d4cbb51224"); // Bluetooth® Low Energy LED Service
1195
+
1196
+
// Bluetooth® Low Energy LED Switch Characteristic - custom 128-bit UUID, read and writable by central
// The real button state is inverted - most boards have an active low button configuration
1291
+
btn_state = !digitalRead(BTN_BUILTIN);
1292
+
btn_state_changed = true;
1293
+
}
1294
+
```
1295
+
1296
+
As you can see, using the `ArduinoBLE` library makes everything easier and cleaner. We end up with a simple `setup()` and `loop()` sketch.
1297
+
1298
+
- In the `setup()` function the board outputs and inputs are set and configured alongside the BLE service and characteristics.
1299
+
- In the `loop()` function we continuously ask if the peripheral is properly connected to a central and then start notifying the push button status and retrieving the app LED status.
1300
+
1301
+
After uploading the sketch to the Nano Matter, it is time to communicate with it via Bluetooth® Low Energy. For this, Silicon Labs has developed a **mobile app** that you can download from here:
0 commit comments