I'm using an Arduino Uno Wi-Fi R2.
#include <ArduinoBLE.h>
BLEService myserv("DE2E82B1-1A23-41B3-A74F-0ED8A0A61E68");
BLEIntCharacteristic mychar("EFDA032A-37D9-40C5-9FB5-7B476FB19970", BLERead | BLEWrite);
const int ledPin = LED_BUILTIN;
int rate;
void setup() {
pinMode(ledPin, OUTPUT);
BLE.begin();
BLE.setLocalName("blank");
BLE.setAdvertisedService(myserv);
myserv.addCharacteristic(mychar);
BLE.addService(myserv);
mychar.writeValue(1000);
BLE.advertise();
}
void loop() {
BLEDevice central = BLE.central();
if (central) {
while (central.connected()) {
mychar.readValue(rate);
if (mychar.written()) {
while (mychar.value()) {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(rate);
}
}
}
}
}
I got to the above code by trying to simplify and repurpose the ArduinoBLE Peripheral LED example.
I am able to change the flash rate once; after that, the Arduino stops communicating with the iPad.