Arduino Tutorial: Get Traveled Distance using ADNS-9800 Laser Mouse Sensor

Picture of Arduino Tutorial: Get Traveled Distance using ADNS-9800 Laser Mouse Sensor
The ADNS-9800 Laser gaming sensor comprises of sensor and VCSEL in a single chip-on-board (COB) package. ADNS-9800 provides enhanced features like programmable frame rate, programmable resolution, configurable sleep and wake up time to suit various PC gamers’ preferences. The advanced class of VCSEL was engineered by PixArt Imaging to provide a laser diode with a single longitudinal and a single transverse mode. This Laser gaming sensor is in 16-pin integrated chip-on-board (COB) package. It is designed to be used with ADNS-6190-002 small form factor (SFF) gaming laser lens to achieve the optimum performance featured in this document. These parts provide a complete and compact navigation system without moving part and laser calibration process is NOT required in the complete mouse form, thus facilitating high volume assembly. The sensor is based on Laser technology, which measures changes in position by optically acquiring sequential surface images (frames) and mathematically determining the direction and magnitude of movement. It contains an Image Acquisition System (IAS), a Digital Signal Processor (DSP), and a four wire serial port. The IAS acquires microscopic surface images via the lens and illumination system. These images are processed by the DSP to determine the direction and distance of motion. The DSP calculates the Δx and Δy relative displacement values. An external microcontroller reads the Δx and Δy information from the sensor serial port. The microcontroller then translates the data into PS2, USB, or RF signals before sending them to the host PC or game console.

In this tutorial You will learn how to connect ADNS-9800 Laser Mouse Sensor to Arduino and Display Traveled Distance (Δx) on 20x4 LCD
Remove these adsRemove these ads by Signing Up

Step 1: Building Circuit

First You Need to Build Circuit
You have to Connect Your Arduino to ADNS-9800 and LCD Screen
You can download Circuit from there:

Step 2: Uploading Code

Picture of Uploading Code
Now Connect Your Arduino to Computer.
Download Arduino Project at
Then Open it, Select Your Board and Your COM Port and Click Upload Button

LakeW21 days ago

Is this your new code with distance displayed?

fishbulb21 month ago

Would this work with an arduino due by using the 3.3v power and not having to convert the sensor to 5V.

Gigi Butbaia (author)  fishbulb21 month ago

If sensor is in 3.3V mode (NOTE: mode isn't changed using code) yes it will work with arduino due (NOTE: code that I have uploaded doesn't show distance in meters, and you can decrease loop delay to speed up sensor, I will upload new code soon)

Hi Gigi,

Do you have personal experience with the Due? I've tried to get it to work but I can't quite figure it out. Do you think the code needs to be altered at all (to define the SPI pins for example)? You wouldn't possibly be able to send me an image of the hardware wiring for the due as you did above for the uno would you? I'm don't need the lcd screen, but I'm just not sure where to attached the sensor pins to the due to have it compatible with the code.

Much appreciated,


That's fantastic Gigi, thank you so much for this. We want to use it for research and this is a great help. Would it be possible to have the next code report the x and y displacement instead of the net total displacement? I've been working on it but I can't quite seem to get the chip to report values other than 0, 1, or 255. I'm new to Arduino, so I think this is likely a simple problem on my coding part.

Thanks again and you rock!
q8naser922 months ago

i have tried using the above connection and code but without lcd and potientimeter by displaying the distance to the serial only and it haven't worked it download no problem but it doesn't specify the distance it just initialize and does nothing please help??

Gigi Butbaia (author)  q8naser922 months ago

Are you using same ADNS-9800 that is in video? if yes then have you activated 5V mode?, have you checked your wiring? can you give me your code? mostly it doesn't initialize because of problems with uploading firmware or connectiong problems with ADNS-9800

I am using the same ADNS-9800 in the video, Same connections in the video (ss-10,mo-11,sc-13,mi-12,mot-2,vi-5v,ag-gnd,dg-gnd). of course i haven't connected an lcd i wanted to read it in the serial which your code provides. about activating 5V mode ho do you activate it? if its in the code I'm using your code so i think you activated

Gigi Butbaia (author)  q8naser921 month ago

To activate +5V mode you have to cut the three traces on the 3.3V side between the exposed sets of pads, and add three solder bridges to the 5V side of the board (Be careful don't damage board).
When you will activate +5V mode and then connect it correctly it will work fine, but remember code that I have uploaded doesn't show distance in meters and you have to decrease loop delay to speedup sensor, sorry for not replying that long (I have been working on a new project which I will upload soon).