Forget something during Black Friday/Cyber Monday? Check out the Week of Deals!
Member Since: April 26, 2012
Country: United States
what's the little piece of adhesive foam for?
is it the "double-sided sticky tape" that you refer to for mounting the module to the board?
ahh... you're getting this stuff from servo city?
might you please explain, or sell separately, the "potentiometer/feedback" shaft as seen here and in your videos?
thank you!
lol - that looked a lot better when I pasted it!!!
as opposed to the example above, here's some code that will get this working right-away in true quadrature fashion. [model #E6A2-CW3C]
sorry if it is wrong to post this here, but it's free to the world, have spark-fun!
// code start
[put pound sign here!]include "digitalWriteFast.h" // google this and install it
const byte pin_A = 2; // connect white wire here
const byte pin_B = 3; // connect black wire here
int A_set = 0;
int B_set = 0;
long pulses = 0;
void setup()
{
pinMode(pin_A, INPUT);
digitalWrite(pin_A, HIGH); // enables pull-up resistor
pinMode(pin_B, INPUT);
digitalWrite(pin_B, HIGH); // enables pull-up resistor
A_set = digitalRead(pin_A);
B_set = digitalRead(pin_B);
attachInterrupt(0, encoderPinChange_A, CHANGE); // pin 2
attachInterrupt(1, encoderPinChange_B, CHANGE); // pin 3
Serial.begin(115200);
}
void loop()
{
Serial.println(pulses);
}
void encoderPinChange_A()
{
A_set = digitalReadFast2(pin_A) == HIGH;
pulses += (A_set != B_set) ? +1 : -1;
}
void encoderPinChange_B()
{
B_set = digitalReadFast2(pin_B) == HIGH;
pulses += (A_set == B_set) ? +1 : -1;
}
I've had great success in narrowing the gap on these simply by gluing a piece of tubing on the LED side, the transistor side... or both.
No public wish lists :(