Page 1 of 1

esp32 bloetooth mouse

Posted: Thu Feb 01, 2024 9:20 am
by Mr.Ambs
hello everyone... I want to make a bluetooth mouse with ESP32. only I'm still confused about creating GPIO parameters to activate the buttons on each board. can anyone help?
this is the code I use
#include <BleMouse.h>

BleMouse bleMouse;
#define Back 25

void setup() {
pinMode(Back,INPUT_PULLUP);
digitalWrite(Baack,HIGH);

Serial.begin(115200);
Serial.println("Starting BLE work!");
bleMouse.begin();
}

void loop() {
if(bleMouse.isConnected()) {
if(digitalRead(Back==LOW)){
Serial.println("Back button click");
bleMouse.click(MOUSE_BACK);
delay(500);}

}

Re: esp32 bloetooth mouse

Posted: Fri Feb 02, 2024 11:29 am
by andrew
I can't advise on that library but I see a couple of errors in your code so try this:

  1. #include <BleMouse.h>
  2.  
  3. BleMouse bleMouse;
  4. #define BACK 25
  5.  
  6. void setup()
  7. {
  8.   pinMode(BACK, INPUT_PULLUP);
  9.   digitalWrite(BACK, HIGH);
  10.  
  11.   Serial.begin(115200);
  12.   Serial.println("Starting BLE work!");
  13.   bleMouse.begin();
  14. }
  15.  
  16. void loop()
  17. {
  18.   if(bleMouse.isConnected())
  19.   {
  20.     if(digitalRead(BACK) == LOW)
  21.     {
  22.       Serial.println("Back button click");
  23.       bleMouse.click(MOUSE_BACK);
  24.       delay(500);
  25.     }
  26.   }
  27. }