Hi all,
I have these encoder below ( Please see encoder );
http://robotus.net/wp-content/uploads/2012/07/manyetik-encoder-forceup.jpg
and I want to do these;
I have already done the 200 RPM DC Motor PWM control and now only I am trying to see position on serial monitor.
(using arduino uno)
I search a lot of code and try in the rotary encoder libraries etc. but
For example when I use this code;
#include <Encoder.h>
Encoder myEnc(2, 3);
void setup() {
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
}
}
I have this result in Serial Monitor;
Basic Encoder Test:
-1
0
1
0
-1
0
1
0
-1
...
I tried a lot of working code and most of them give me same result
But I want to have
Basic Encoder Test:
1
2
3
4
...
something like that. I am wondering is the problem could be my encoder type ? Because, I have never seen any project example in net.
So, anybody have an idea about to use these kind of encoder with interrupt.
Thanks.