Sunday, January 18, 2015

Using Computer Mouse as Scanning Device for Arduino

I happened to have a wireless keyboard/mouse combo lying around with a broken USB-dongle. Basically unusable for regular use, but of course ideal for some thinkering.

I recently read an article about using the image sensor as input device for Arduino or other MCU and I wondered if I could repurpose my mouse for this.

So, I took my mouse apart and found out it is based on the Avago ADNS-5030.

I first cut all the traces going to the local microcontroller, solder some pins on the sensor and hooked up my Arduino Mini Pro 3.3V/8Mhz as follows, I took the 3.3V power from the Arduino too :


NameADNS5030Mini Pro
VCC7VCC
GND6GND
NRST39
NCS48
CLK513
MOSI811
MISO112
Reading the datasheet, shows SPI has to be configured in SPIMODE 2 (Pol=1, Pha = 0). Clockspeed is 1Mhz, so the DIVIDER is set to 4.

A quick check allow to verify register 0/1 and to read ChipId and Revision, respectively 0x11 and 0x00.

I ran a small demo reading the Motion-register and reading the dX and dY movement. No big deal.

Now I wanted to make sure I could readout the 15x15 pixel imagesensor. For this you need to readout the Grabber-register (0x0B), check that the MSB is '1' and then use the 7 remaining bits as intensity.

I connected my IL9301 TFT screen to my Arduino and used the Adafruit GFX library to draw the pixels on the screen.

On the software side it's a bit tricky because IL9301 works in SPIMODE=3 and divider 2, so we are changing the SPI-parameters on the fly to make it happen.

This is the setup :
The image sensor has approx. 0,1mm pixel resolution, the 'e' on the TFT-screen corresponds to 1 character from the cardboard.


No comments:

Post a Comment