Button control through BLE communication

hello!
I am currently using the RN52s as an Arduino tool.
I made a board using the RN52s chip.
Using the RN52s chip, we were able to successfully operate the mouse cursor and bleuart functions simultaneously on a mobile phone.
First of all, let me tell you about the features of my board.
There are six buttons, and each button functions as a mouse cursor and scroll function on the phone.
Here, when I press key a, the mouse cursor moves to coordinates 500,800 on my phone. When I receive a command through bleuart, I want to make the mouse cursor move to a different coordinate when I press key a.
However, my code does not recognize the current command even though it is received.
Do you know the reason or a solution?
The board used in the Arduino tool is Adafruit Feather nRF52932.
Let me share my code.

void loop() {
  static bool receivedA = false; // Flag to track if 'A' was received

  // Check if BLEUART has data available
  if (bleuart.available()) {
    char receivedChar = (char)bleuart.read();
    Serial.println(receivedChar);
    
    if (receivedChar == 'A') {
      receivedA = true; // Set flag if 'A' is received
    } else {
      receivedA = false; // Reset flag if any other character is received
    }
  }

  // Check if 'A' was received or not
  if (receivedA) {
    taskBLE(); // Call taskBLE when 'A' is received
  } else {
    taskBLE_MOUSE(); // Call taskBLE_MOUSE when no 'A' received
  }

  // Forward data from HW Serial to BLEUART
  while (Serial.available()) {
    delay(2); // Delay to wait for enough input, since we have a limited transmission buffer
    uint8_t buf[64];
    int count = Serial.readBytes(buf, sizeof(buf));
    bleuart.write(buf, count);
  }
}

Hi @lastnemo,

welcome to the arduino-forum.
I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

I do not understand what you mean with that.
You should describe in much more detail what device is doing what to change what device to do what doing different.

one example:
You have a computer running windows 11.
Your real normal BLE-mouse is connected to this computer.

Now you want to use your RN52 microcontroller to send a command to the Windows PC which will change the functions of left and right mouse-button??

I guess you mean it somehow different. But you should describe in this grade of detail what you exactly want to do

best regards Stefan

1 Like

Thank you for your kind reply. I posted a description of my project again.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.