esp32 bloetooth mouse

Forum for posting topics and questions about anything.
Post Reply
Mr.Ambs
Posts: 1
Joined: Thu Feb 01, 2024 9:16 am

esp32 bloetooth mouse

Post by Mr.Ambs » Thu Feb 01, 2024 9:20 am

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);}

}

andrew
Site Admin
Posts: 1407
Joined: Sun Aug 05, 2012 4:15 pm

Re: esp32 bloetooth mouse

Post by andrew » Fri Feb 02, 2024 11:29 am

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. }
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “General Discussion”