Simple ESP32 project: I Built a Bluetooth Mouse

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

Комментарии •

  • @masteralive603
    @masteralive603 11 дней назад

    Nice ♥♥♥

  • @faizanhaque8805
    @faizanhaque8805 3 месяца назад +1

    amazing video buddy! make more amazing projects like this

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  3 месяца назад +1

      Thanks so much, I really appreciate it! A like, sub, and share would help me a lot at this stage!

  • @Amy-kh3zl
    @Amy-kh3zl 2 месяца назад

    Nice video!!!
    can you make a simple/mid project using esp32,how to use potentiometer with it,and further explain how to use joystick and the pins?👌👍

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  2 месяца назад

      @@Amy-kh3zl Thank you for the feedback!! Yes, that's a great suggestion! :) I just started, subs shares and like would really help me a lot to grow and keep making video like this! :)

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  Месяц назад

      I made the Joystick tutorial! :)

  • @Adrian-od8iu
    @Adrian-od8iu 11 дней назад

    same code for windows? also still waiting on your code, i have some cool ideas to add

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  6 дней назад

      Yes, i am using the Arduino IDE that you can use also on Windows. I am planning to make a GitHub to release the code, stay tuned!

  • @yvreuctug
    @yvreuctug 2 дня назад +1

    CODE???????????????????

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  День назад

      Hi!! Thank you for your interest, I am planning to create a GitHub repository soon, to release codes. Stay tuned!
      Consider that any sub like and share woul really help me a lot at this stage!

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  21 час назад

      Meanwhile I am pasting it here below.
      Consider that a like a share and a sub would greatly help me at this stage.
      Let me know if it works.
      ____________________________
      #include "BleMouse.h" // Include the Bluetooth Mouse library
      // Create a BluetoothMouse object
      BleMouse bleMouse;
      // Define the pins for the joystick and the switch
      const int vxPin = 32; // Joystick x-axis (horizontal) -> GPIO 32 (analog)
      const int vyPin = 33; // Joystick y-axis (vertical) -> GPIO 33 (analog)
      const int swPin = 25; // Joystick button switch -> GPIO 25 (digital)
      // Sensitivity for cursor movement
      int sensitivity = 20; // Adjust this value to control cursor speed
      // Define the new center values and dead zone for joystick movement
      int centerValue = 3000; // Central value based on your joystick's calibration
      int deadZone = 200; // Wider dead zone to prevent small movements
      void setup() {
      // Initialize serial communication for debugging
      Serial.begin(9600);
      // Begin Bluetooth Mouse
      bleMouse.begin();
      Serial.println("Bluetooth Mouse is ready to pair");
      // Configure analog pins with pull-down resistors if needed
      pinMode(vxPin, INPUT_PULLDOWN);
      pinMode(vyPin, INPUT_PULLDOWN);
      // Configure the joystick button pin
      pinMode(swPin, INPUT_PULLUP); // Joystick button uses pull-up resistor
      }
      void loop() {
      if (bleMouse.isConnected()) {
      // Read joystick values
      int vxValue = analogRead(vxPin);
      int vyValue = analogRead(vyPin);
      int swValue = digitalRead(swPin); // Read joystick button state
      // Print joystick values for debugging
      Serial.print("VX: ");
      Serial.print(vxValue);
      Serial.print(" | VY: ");
      Serial.println(vyValue);
      // Center the readings around the new center value (3000)
      int xDeviation = vxValue - centerValue;
      int yDeviation = vyValue - centerValue;
      int deltaX = 0;
      int deltaY = 0;
      // Map the deviations to cursor movement if outside the widened dead zone
      if (abs(xDeviation) > deadZone) {
      deltaX = map(xDeviation, -2048, 2047, -sensitivity, sensitivity);
      }
      if (abs(yDeviation) > deadZone) {
      deltaY = map(yDeviation, -2048, 2047, -sensitivity, sensitivity);
      }
      // Move the cursor based on joystick input
      bleMouse.move(deltaX, -deltaY); // Invert deltaY for natural movement
      // Handle joystick button press for mouse click
      if (swValue == LOW) { // Button is pressed (active low)
      if (!bleMouse.isPressed(MOUSE_LEFT)) {
      bleMouse.press(MOUSE_LEFT); // Press left mouse button
      }
      } else {
      if (bleMouse.isPressed(MOUSE_LEFT)) {
      bleMouse.release(MOUSE_LEFT); // Release left mouse button
      }
      }
      delay(20); // Smoother movement
      } else {
      Serial.println("Mouse not connected");
      delay(1000); // Check every second if the Bluetooth mouse is connected
      }
      }

  • @lochobhai
    @lochobhai 2 месяца назад +1

    povide your code

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  2 месяца назад

      Thank you for your interest. I am going to paste the code in the description.
      Consider that a like, a sub, and a share would greatly help me at this stage!

    • @lochobhai
      @lochobhai 2 месяца назад

      Thanks ❤❤❤

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  2 месяца назад +2

      @@lochobhai I am actually pasting it here:
      _____________________
      #include "BleMouse.h" // Include the Bluetooth Mouse library
      // Create a BluetoothMouse object
      BleMouse bleMouse;
      // Define the pins for the joystick and the switch
      const int vxPin = 32; // Joystick x-axis (horizontal) -> GPIO 32 (analog)
      const int vyPin = 33; // Joystick y-axis (vertical) -> GPIO 33 (analog)
      const int swPin = 25; // Joystick button switch -> GPIO 25 (digital)
      // Sensitivity for cursor movement
      int sensitivity = 20; // Adjust this value to control cursor speed
      // Define the new center values and dead zone for joystick movement
      int centerValue = 3000; // Central value based on your joystick's calibration
      int deadZone = 200; // Wider dead zone to prevent small movements
      void setup() {
      // Initialize serial communication for debugging
      Serial.begin(9600);
      // Begin Bluetooth Mouse
      bleMouse.begin();
      Serial.println("Bluetooth Mouse is ready to pair");
      // Configure analog pins with pull-down resistors if needed
      pinMode(vxPin, INPUT_PULLDOWN);
      pinMode(vyPin, INPUT_PULLDOWN);
      // Configure the joystick button pin
      pinMode(swPin, INPUT_PULLUP); // Joystick button uses pull-up resistor
      }
      void loop() {
      if (bleMouse.isConnected()) {
      // Read joystick values
      int vxValue = analogRead(vxPin);
      int vyValue = analogRead(vyPin);
      int swValue = digitalRead(swPin); // Read joystick button state
      // Print joystick values for debugging
      Serial.print("VX: ");
      Serial.print(vxValue);
      Serial.print(" | VY: ");
      Serial.println(vyValue);
      // Center the readings around the new center value (3000)
      int xDeviation = vxValue - centerValue;
      int yDeviation = vyValue - centerValue;
      int deltaX = 0;
      int deltaY = 0;
      // Map the deviations to cursor movement if outside the widened dead zone
      if (abs(xDeviation) > deadZone) {
      deltaX = map(xDeviation, -2048, 2047, -sensitivity, sensitivity);
      }
      if (abs(yDeviation) > deadZone) {
      deltaY = map(yDeviation, -2048, 2047, -sensitivity, sensitivity);
      }
      // Move the cursor based on joystick input
      bleMouse.move(deltaX, -deltaY); // Invert deltaY for natural movement
      // Handle joystick button press for mouse click
      if (swValue == LOW) { // Button is pressed (active low)
      if (!bleMouse.isPressed(MOUSE_LEFT)) {
      bleMouse.press(MOUSE_LEFT); // Press left mouse button
      }
      } else {
      if (bleMouse.isPressed(MOUSE_LEFT)) {
      bleMouse.release(MOUSE_LEFT); // Release left mouse button
      }
      }
      delay(20); // Smoother movement
      } else {
      Serial.println("Mouse not connected");
      delay(1000); // Check every second if the Bluetooth mouse is connected
      }
      }

    • @im_anhar
      @im_anhar 16 дней назад

      ​@@ThinkingThings-q4p code does not work

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  21 час назад

      @@im_anhar What kind of error do you get?

  • @karelbenda5322
    @karelbenda5322 2 дня назад +1

    Interesting video, but the code is missing. Please fill it in.

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  День назад

      Hello! Thank you so much for your interest! I'm planning to create a GitHub repository soon to share my codes, so stay tuned for updates.
      Your support through subscribing, liking, and sharing would mean the world to me and help me grow at this stage!

    • @karelbenda5322
      @karelbenda5322 День назад

      @@ThinkingThings-q4p My support through subscribing, liking, and sharing only makes sense if your channel is useful to me. If the author doesn't bother to publish the code, I won't support, like, or subscribe. It makes no sense. No code = no like or channel subscription.

    • @ThinkingThings-q4p
      @ThinkingThings-q4p  21 час назад

      @@karelbenda5322 Thank you for your feedback! I understand how helpful having access to the code can be, and I truly appreciate your perspective. My channel focuses on sharing ideas, demonstrations, and inspiration for DIY projects. As I mentioned, I plan to create a GitHub repository soon to share my projects more broadly.
      Of course, the choice to subscribe is entirely yours, and I respect that. Thanks again for your input, and I hope to see you around!