Optical mouse sensors internally capture low-resolution grayscale images of the surface to track movement. This project taps into that data stream to read and display those images.
The sensor being used here is an Agilent ADNS-2051 from an old Logitech mouse. The datasheet can be found here. It can easily be adapted to work with other optical mouse sensors of the same family.
An Arduino UNO was used for bit-banging the serial interface of the mouse sensor. The connections are as follows:
- ADNS-2051 VCC to Arduino 5V
- ADNS-2051 GND to Arduino GND
- ADNS-2051 SCLK to Arduino pin 2
- ADNS-2051 SDIO to Arduino pin 3
- ADNS-2051 PD to Arduino pin 4
The Arduino sketch mousecam.ino initializes the sensor and continuously reads image frames from it. serial_cam.py is a Python script that reads the image data from the Arduino over serial and displays it using OpenCV.
Make sure to install the required Python packages:
pip install pyserial opencv-pythonTo run the Python script, use:
python serial_cam.py <PORT>
