1.首先,需要为Arduino Portenta H7板安装适当的蓝牙库。将以下代码行添加到Arduino IDE中的“Sketch”>“Include Library”> “Manage Libraries”的搜索栏中:
#include
2.接下来,需要开启板子的蓝牙功能。请将以下代码行添加到setup()函数:
if (!BLE.begin()) { Serial.println("starting BLE failed!"); while (1); }
3.要连接到PC上的Windows,请将以下代码行添加到setup()函数:
BLE.setLocalName("Arduino Portenta"); BLE.setAdvertisedService(0x180D); // BLE heart rate service BLE.addService(service); BLE.advertise();
4.最后,要从PC上的Windows连接,您需要搜索要连接的蓝牙设备,然后将其与Windows配对。一旦设备完成配对过程,您可以使用Arduino Bluetooth LE官方库中提供的示例进行通信。
以上是使用Arduino Portenta H7开发板通过蓝牙连接到Windows的解决方法。