I have read a bunch of them and I am still in need of help processing data from a optical mouse sensor I have either a paw3402 or a mcs12085 (with a seperate resonator) to work with.
Right now I am trying to just get x, y values but eventually I want to interpret those vales and make the arduino spin a haptic motor every time the sensor registers movement over "x" values and then reset to do it again... Can anyone help me???
Right now all I get back is repeating 14640 line after line.
I am jumping off something done by John Graham-Cumming (see below for ino sketch .cpp and .h data)
Thanks for getting back with me I am using 4 and 7 for now. I inserted the mcs12085_int() and now get data in the serial monitor but it is gibberish.. see screen capture attached
tested baud rate change and no luck. Is there something in the .cpp file that is not converting it to a legible integer? Each line of gibberish is only created when the sensor moving; with no movement it is only a comma.
Got it to give me tangible data in x or y but not together. this is fine because I am only concerned with one axis... So
Can anyone help me with the script to record and sum the outputs from my chip and when the total movement is greater than +/- 10 it runs a vib motor sketch (below) and resets for next delta movement?
yep your right. I overlooked that fact. I am very new to c++ and am learning the commands as I go. So please be patient.
Now I am trying to sum the outputs and generate my response it works at the correct movement rate. But I want it to fire 3x when I move one large jump that is 3 times my threshold..? should I be using if else statments or sum function? is an if statement the best way to deal with the negative values?
int i = mcs12085_dy();
for (i; i >= 4; i = i + i + i + i + i + i + i + i + i + i + i + i + i)
{
vib();
}
for (i; i >= 8; i=i)
{
vib2();
}
for (i; i >= 19; i = i)
{
vib3();
}
// for (int i = mcs12085_dy(); 19 < i < 24; i = i + i + i + i + i)
// {
// vib4();
// }
void vib()
{
digitalWrite(motorPin, HIGH);
delay(5);
digitalWrite(motorPin, LOW);
}
void vib2()
{
digitalWrite(motorPin, HIGH);
delay(5);
digitalWrite(motorPin, LOW);
delay(150);
digitalWrite(motorPin, HIGH);
delay(5);
digitalWrite(motorPin, LOW);
}
void vib3()
{
digitalWrite(motorPin, HIGH);
delay(5);
digitalWrite(motorPin, LOW);
delay(150);
digitalWrite(motorPin, HIGH);
delay(5);
digitalWrite(motorPin, LOW);
delay(150);
digitalWrite(motorPin, HIGH);
delay(5);
digitalWrite(motorPin, LOW);
Thanks. I realize that there are multiple ways to tackle this and I have strugled finding the best way. I was trying to write the script for total motion + motion and didn't know how to write it. Thanks a lot; especially for including the description text next to your code! THANKS again from another novice c++/duino guy.
The mouse I'm using has a MX8733 optical sensor 8-pin chip. It seems very similar to the MCS-12086.
I'm also using an Arduino UNO. I'm connected fine. And I'm running the Arduino code just like yours.
However, I'm only getting -1 for both X and Y. Nothing else.
Could you post a pic of how you wired your mouse chip? I don't get what I'm doing wrong.