hello , when i connect my arduino with app . App will show text invalid UIID , how i will fix it ? i want app take characteristic and adress from list picker and i click button arduino do what i want . Board is arduino nano RP2040 connect
code arduino : #include <ArduinoBLE.h>
#include <Servo.h>
BLEService rcCarService("19B10000-E8F2-537E-4F6C-D104768A1214"); // Define a custom service UUID
BLECharCharacteristic cmdCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLEWrite); // Define a custom characteristic UUID
#define SERVO_PIN 3
#define MOTOR_1A 7
#define MOTOR_1B 8
Servo steeringServo;
void executeCommand(char cmd);
void setup() {
Serial.begin(9600);
pinMode(SERVO_PIN, OUTPUT);
pinMode(MOTOR_1A, OUTPUT);
pinMode(MOTOR_1B, OUTPUT);
steeringServo.attach(SERVO_PIN);
while (!Serial) {
}
// Start BLE
if (!BLE.begin()) {
Serial.println("failed to initialize BLE!");
while (1) {
}
}
BLE.setLocalName("RCCar"); // set the local name peripheral advertises
BLE.setAdvertisedService(rcCarService); // set the UUID for the service this peripheral advertises
rcCarService.addCharacteristic(cmdCharacteristic); // add the characteristics to the service
BLE.addService(rcCarService); // add the service
BLE.advertise(); // start advertising
Serial.println("Bluetooth® device active, waiting for connections...");
}
void loop() {
// listen for Bluetooth® Low Energy peripherals to connect:
BLEDevice central = BLE.central();
// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
// while the central is still connected to peripheral:
while (central.connected()) {
// if the remote device wrote to the characteristic,
// use the value to control the LED:
if (cmdCharacteristic.written()) {
executeCommand(cmdCharacteristic.value());
}
}
// when the central disconnects, print it out:
Serial.print("Disconnected from central: ");
Serial.println(central.address());
}
}
void executeCommand(char cmd) {
switch (cmd) {
case 'F':
// Forward motion
digitalWrite(MOTOR_1A, HIGH);
digitalWrite(MOTOR_1B, LOW);
break;
case 'B':
// Backward motion
digitalWrite(MOTOR_1A, LOW);
digitalWrite(MOTOR_1B, HIGH);
break;
case 'L':
// Turn left
steeringServo.write(45);
break;
case 'R':
// Turn right
steeringServo.write(0);
break;
case 'S':
// Stop
digitalWrite(MOTOR_1A, LOW);
digitalWrite(MOTOR_1B, LOW);
break;
}
}