Close
0%
0%

Connecting a Mouse to an Arduino

Connecting a mouse to an Arduino is simple. With just a few wires, we can easily integrate it into our Arduino projects.

Public Chat
Similar projects worth following
132 views
0 followers
Connecting a mouse to an Arduino is simple. With just a few wires we can easily integrate it into our Arduino projects. With the method that I describe in this post, the mouse can act as a sensor for determining positions or movements of vehicles, robots, for example.

First, it is important to mention that this only works with mice that support the PS/2 protocol. Modern mice, for example the wireless ones only support USB and don't "understand" PS/2 any more.
PS/2 is a serial protocol, similar to the UART protocol. But unlike UART, PS/2 is a synchronous protocol, which means that data and clock use different wires.

With this, it is easy to use the Arduino's builtin serial interface to receive the PS/2 data from the mouse. Please watch the video if you want to know more.

  • 1 × PS/2 mouse or PS/2 compatible USB mouse
  • 1 × Atmega 328 based Arduino (i.e. Uno or Nano)

  • 1
    Wiring

    Here are two pictures that show how to wire a mouse with PS/2 connector and a PS/2 compatible USB mouse to the Arduino Nano or UNO.

    The data goes into the Arduino's Rx pin, clock goes into pin 4. With the 10k resistor between Data and +5V, it is still possible to use the interface for uploading programs while the mouse is connected. After development is done, the resistor can be removed.

  • 2
    Build the Example

    There is a small example sketch that lets you control some LEDs with a mouse. Wire the example like shown below:


    Then, all that's left to do is download the example sketch from Github, and flash it on the Arduino.

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates