Skip to main content

Arduino HID Emulator

arduino-hid-emulator is a Python library designed to control HID devices (keyboard and mouse) emulated using Arduino. The library allows you to send commands to control mouse movements, key presses, and mouse button actions, as well as perform calibration for precise positioning.

Features

  • Mouse Control:

    • Direct movement by specified offset.
    • Smooth mouse movement using a Bézier curve.
    • Press, release, and click mouse buttons.
  • Keyboard Control:

    • Press and release keys.
    • Simulate key combinations (e.g., Ctrl + C).
  • Calibration:

    • Automatic calibration of mouse movement factors for precise positioning.
  • Flexibility:

    • Adjustable minimum and maximum duration for mouse movements.
    • Easy connection and control via serial port.

Installation

Ensure Python 3.x is installed on your system, then install the library using pip:

pip install arduino-hid-emulator

Requirements

  • Arduino with HID support (e.g., Arduino Pro Micro or Leonardo).
  • Upload the Arduino sketch (hid_emulator.ino) located in the arduino/hid_emulator directory.
  • Python libraries:
    • pyserial
    • pyautogui

Quick Start

  1. Connect Arduino: Upload the hid_emulator.ino sketch to your Arduino board and connect it to your computer via USB.

  2. Create a connection object:

    from arduino_hid_emulator.arduino import ArduinoConnection
    from arduino_hid_emulator.mouse import MouseController
    
    arduino = ArduinoConnection()
    mouse = MouseController(arduino)
    
  3. Usage example:

    # Move the mouse to a specified point
    mouse.move_direct(100, 100)
    
    # Smoothly move the mouse to a specified point
    mouse.mouse_move(500, 500, duration_min=1000, duration_max=2000)
    
    # Click the left mouse button
    mouse.click("left")
    
  4. Close the connection:

    arduino.close()
    

Calibration

For precise movement, it is recommended to perform calibration:

mouse.calibrate()

Calibration is performed automatically, adjusting mouse movement factors.

Project Structure

  • arduino_hid_emulator/ — source code of the library.
  • arduino/hid_emulator/ — sketch for uploading to Arduino.
  • examples/ — usage examples.

License

The project is distributed under the GPL-3.0 license. You are free to use, modify, and distribute the library under its terms.

Contributing

If you want to suggest improvements, report issues, or contribute, create a pull request or open an issue in the project repository.


Note: Make sure the Arduino sketch is uploaded and the device supports HID.

Release files for arduino-hid-emulator 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arduino-hid-emulator 0.4.1
File Size Uploaded
arduino_hid_emulator-0.4.1.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arduino-hid-emulator 0.4.1
File Interpreter ABI Platform
arduino_hid_emulator-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.9 kB

Release files / arduino_hid_emulator-0.4.1.tar.gz

Download URL arduino_hid_emulator-0.4.1.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
756764f8a4dd6e19c4c3645ea89faf3a903756c7b9f34dc9a1cdd892ded01524
BLAKE2b-256 checksum
How to use checksums
fef92299ef620c42ba8838ec84e3ea692c6d051c4ac9ece938e87223a46631b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / arduino_hid_emulator-0.4.1-py3-none-any.whl

Download URL arduino_hid_emulator-0.4.1-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e62389076d0529784b52bf1619f35e6a4a310f6aecf56bd120294895376cb85
BLAKE2b-256 checksum
How to use checksums
ece72efb3f8d6dfc0386923ef7c65f4947002b2eb6f065b88d8cc93c5787cbd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page