Go Down

Topic: Trouble interfacing with an ADNS-2610 optical mouse (Read 4294 times) previous topic - next topic


I am trying to use code that was posted in another thread on this forum. The code communicates with an ADNS-2610 optical mouse. I am using the code below;
Code: [Select]
[color=blue]// This example reads out the PixArt PAN3101 Optical Navigation Sensor
// It's used in many cheap optical mouses.
// For support for the Agilent ADNS-2051, ADNS-2083 or ADNS-2610, move
// the files for your mouse to the folder with the OptiMouse files.
// Then uncomment the right header files and object instances below.
// The Arduino will keep track of a (x, y) coordinate by increasing
// or decreasing the x and y variables by dx and respectively dy.
// Every 128th sample it reports the current (x, y) over the Serial.
// Written by Martijn The -> post [at] martijnthe.nl
// Tutorial: http://www.martijnthe.nl/optimouse/
// Based on the sketches by Beno?t Rousseau

#include "C:\Documents and Settings\Kevin Wynne\Desktop\arduino-0022\ADNS2610.h"

#define SCLK 2                            // Serial clock pin on the Arduino
#define SDIO 4                           // Serial data (I/O) pin on the Arduino

ADNS2610 Optical1 = ADNS2610(SCLK, SDIO);

signed long x = 0;                        // Variables for our 'cursor'
signed long y = 0;                        //

int c = 0;                                // Counter variable for coordinate reporting

void setup()
  Optical1.begin();                       // Resync (not really necessary?)

void loop()

    x += Optical1.dx();                   // Read the dX register and in/decrease X with that value
    y += Optical1.dy();                   // Same thing for dY register.....

  if (c++ & 0x80)
  {                                       // Report the coordinates once in a while...
    Serial.print(x, DEC);
    Serial.print(" y=");
    Serial.print(y, DEC);
    c = 0;                                // Reset the report counter

I am getting the following errors:

Optical_Mouse.cpp.o: In function `__static_initialization_and_destruction_0':
C:\DOCUME~1\KEVINW~1\LOCALS~1\Temp\build8919888951995157087.tmp/Optical_Mouse.cpp:25: undefined reference to `ADNS2610::ADNS2610(unsigned char, unsigned char)'
Optical_Mouse.cpp.o: In function `loop':
C:\DOCUME~1\KEVINW~1\LOCALS~1\Temp\build8919888951995157087.tmp/Optical_Mouse.cpp:42: undefined reference to `ADNS2610::dx()'
C:\DOCUME~1\KEVINW~1\LOCALS~1\Temp\build8919888951995157087.tmp/Optical_Mouse.cpp:43: undefined reference to `ADNS2610::dy()'
Optical_Mouse.cpp.o: In function `setup':
C:\DOCUME~1\KEVINW~1\LOCALS~1\Temp\build8919888951995157087.tmp/Optical_Mouse.cpp:36: undefined reference to `OptiMouse::begin()'

I was hoping some one would be able to help me.




It looks like you just pointed to a copy of ADNS2610.h without installing the ADNS2610 library.

Take the ADNS2610 files (.c or .cpp and .h) and put them in a directory called "libraries/ADNS2610/" in the directory where Arduino keeps your sketches.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp



I moved the files that you suggested and I am still getting the same errors.

Do you have any other ideas.



Hello Kevin,
i have a similar problem, but with the ADNS2051. My post is here, but in german.
You can help me?


I got the sketch to work by:

1) Adding "#include <OptiMouse.h>" above the line  "#include <ADNS2610.h>"

2) Edit OptiMouse.h to remove the line "#include "WConstants.h""

Note that you have to move ADNS2610 .h out of the 'drivers' directory and into the same directory as OptiMouse.h
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


Jun 29, 2011, 12:25 pm Last Edit: Jun 29, 2011, 07:46 pm by kucky Reason: 1
Many many thanks. My error messages are gone. But my mistake was that I set the WProgram.h had included the wrong. Now I can continue to tinker.
Best regards Willi

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131