Go Down

Topic: Ways to improve optical mouse sensor tracking (Read 11445 times) previous topic - next topic


Optics fast enough to transmit 100 GB/s over optical cable, something wrong with your hardware configuration. Can you post your schematic/drawings?


Jul 27, 2011, 09:09 am Last Edit: Jul 27, 2011, 09:12 am by Jabberwock Reason: 1
I am not sure the optics network guys use exactly the same photocells as I do...

I attach the diagram, hope it is clear enough.

The code is:

Code: [Select]
int PinA = 2;
int PinB = 3;
int Last = 0;
int n = 0;
unsigned long timeold;
int delta;
int distance;

void setup() {
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
timeold = millis();

void loop(){
n = (analogRead(PinA) > 505);
if ((Last == 0) && (n == 1)) {
if (analogRead(PinB) > 500) {
delta =  millis() - timeold;
timeold = millis();
// reverse
if (n == 1) {
Last = 1;
Last = 0;
Serial.print (analogRead(PinA));
Serial.print ("/");
Serial.print (analogRead(PinB));
Serial.print ("/");
Serial.println (delta);


You must use photodiodes or phototransistors.  LDRs are incredibly slow.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Great news for a change!

Hall sensors and magnets work perfectly! No skipping, no delay, no need for debouncing. They are so precise I just placed two sensors next to each other and I can detect the change of direction with just one pass of a magnet...

I've placed eight magnets around the wheel (the glued encoder chart from the previous solution was quite useful for this :) ). I think I could do even sixteen, but for now this is good enough - the time between the pulses is below 100 ms, which is comparable to analog game controllers.

Funny thing is, I've almost had another solution - I've recovered an IR phototransistor and emitter from an old mouse and wanted to count the teeth on the wheel. I've got the wiring part all done when the magnets have arrived...

Anyway, thank you all for invaluable help, I've learned heaps doing this!

Go Up