rucek / arduino-ps2-mouse

37 stars 10 forks source link

Works on PS2 ball mouse but not optical PS2 mouse #1

Open alchle opened 7 years ago

alchle commented 7 years ago

Have you run across the issue where a ps2 ball mouse works great, but a ps2 optical mouse does not work. It gets stuck on the line that is check for the clock to go low [waitForClockState(LOW);]. Any ideas? Thanks

vance commented 7 years ago

I'm also having this problem. Did you ever figure this out?

alchle commented 7 years ago

I never got the optical mouse working with this PS2Mouse code (bummer) (PS2 worked great), but did get the optical mouse working with a different set of code. I used https://github.com/zapmaker/OptiMouse. I took apart several mice and found one stenciled with 2083... thus was able to use the ADNS2083.h library from that webpage. I needed to have the following in the library folder for it to compile: ADNS2083.cpp ADNS2083.h OptiMouse.cpp OptiMouse.h

This was the base code I started with: /////////////////////////////////////////////////////////////////////////////////////////// // This example reads out the PAN3101 Optical Navigation Sensor // It's used in many cheap optical mouses. // // For support for the Agilent ADNS-2051 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 reads out the dx register and passes it through // the serial port, at a regular interval. So practically, // it measures the speed of the surface. // // Written by Martijn The -> post [at] martijnthe.nl // Tutorial: http://www.martijnthe.nl/optimouse/ // Based on the sketches by Beno”t Rousseau

// #include "PAN3101.h" // #include "ADNS2051.h" // #include "ADNS2610.h" // #include "ADNS2620.h"

include "ADNS2083.h"

define SCLK 2 // Serial clock pin on the Arduino

define SDIO 3 // Serial data (I/O) pin on the Arduino

// PAN3101 Optical1 = PAN3101(SCLK, SDIO); // Create an instance of the PAN3101 object // ADNS2051 Optical1 = ADNS2051(SCLK, SDIO); // ADNS2610 Optical1 = ADNS2610(SCLK, SDIO); // ADNS2610 Optical1 = ADNS2610(SCLK, SDIO); ADNS2083 Optical1 = ADNS2083(SCLK, SDIO);

void setup() { Serial.begin(9600); Serial.println("ADNS2083.h"); Serial.println("Starting..."); Optical1.begin(); // Resync (really necessary?) }

void loop() { // It's also possible to check whether the internal counter of the sensor // has rolled over (overflow), on the PAN3101 and the ADNS2051:

// Optical1.updateStatus(); // if (Optical1.dxOverflow()) Serial.println("Overflow...");

Serial.print("dx =\t"); Serial.print(Optical1.dx(), DEC); Serial.print("\tdy =\t"); Serial.println(Optical1.dy(), DEC); delay(5); } //////////////////////////////////////////////////////////////////////////////////

vance commented 7 years ago

Thanks. I will look at my chips. This is actually funny because I ended up getting an "optical flow odometry" camera which is a 16x16 pixel optical camera attached to a 2083 microchip. I was able to get data, but the camera was not sensitive enough to light or faulty, and only responded if i shined a light right into the optics. bummer.