How to get microcontroller to act as keyboard for macros + shortcuts

Discussion in 'The Projects Forum' started by -live wire-, Apr 16, 2019.

  1. -live wire-

    Thread Starter Active Member

    Dec 22, 2017
    856
    72
    Hi, I would like to make it so that my ESP32 board can act as a USB keyboard and ideally a mouse too. It might use ultrasonic sensors, a simple touchscreen, or other inputs. The main use is probably macros. Can anyone help me find the right library to do this?
     
  2. -live wire-

    Thread Starter Active Member

    Dec 22, 2017
    856
    72
    Also another idea is using my passwords and using it as a physical key to enter them.
     
  3. Raymond Genovese

    Well-Known Member

    Mar 5, 2016
    1,517
    893
  4. -live wire-

    Thread Starter Active Member

    Dec 22, 2017
    856
    72
    Thanks, but I don't have an Arduino pro micro, and I don't want to have to buy something I could do for free and better (using software on a better microcontroller). So how do I do it with an ESP32?
     
  5. Raymond Genovese

    Well-Known Member

    Mar 5, 2016
    1,517
    893
    Well, you have to walk before you can run - right? That is actually a pretty good tutorial and I think that you would gain a lot of understanding about HID that would come in handy. You could even get to the point where you could tackle translating the code in the tutorial to the ESP using the Arduino C/IDE.

    If you want to just skip all that, search and find something more to your liking...search for ESP32 as HID device or as keyboard and so on.
    This one looks interesting https://github.com/asterics/esp32_mouse_keyboard

    But, I have not done specifically what you want to do , so I am just giving you an idea of how I would go about doing it.
     
    -live wire- likes this.
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    4,345
    1,603
    You do realize that these functions don’t require an Arduino Pro Micro? The article was written some time ago. Recent Arduinos can also do the job.

    If you want to use the ESP32, be prepared to write a lot of code to emulate the Arduino functions.

    You can use a microprocessor in the Arduino class of microprocessors. Or you can start from scratch and write the code for the functions already available on another platform.

    The choice is up to you. Use available, tested and supported code. Or write your own. Good luck
     
    -live wire- likes this.
  7. -live wire-

    Thread Starter Active Member

    Dec 22, 2017
    856
    72
    What about using an arduino nano first? While in the future I might want to do something requiring more memory, processing power, bluetooth enabled, etc, it seems starting simpler is the smarter thing to do.
     
  8. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    4,345
    1,603
    What about it? Should work,,.

    A Nano is a microprocessor in the Arduino class.
     
  9. -live wire-

    Thread Starter Active Member

    Dec 22, 2017
    856
    72
    I tried it and the library gave me some issues. I looked and it said the builtin one only works with certain boards according to the arduino website.
     
    Last edited: Apr 17, 2019
  10. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    4,345
    1,603
    I have a few questions for clarity.
    • What library?
    • What issues?
    • The built in what?
    • What boards?
    I want to help. And know your objective. But without the information above, don’t know how to respond.
     
  11. Raymond Genovese

    Well-Known Member

    Mar 5, 2016
    1,517
    893
    ...and therein lies the crux of the biscuit. Do you want to undertake this as a project that requires a lot of learning and understanding and problem solving to get where you want to go...

    https://hackaday.com/2012/06/29/turning-an-arduino-into-a-usb-keyboard/

    ...or do you want something that is turn-key and works with a minimum of time and effort?

    https://www.adafruit.com/product/1535

    There is no shame in either route, it just depends on how you want to get there.
     
    -live wire- and djsfantasi like this.
Loading...