hi there,
i got a rotary encoder from sparkfun which i have connected to a arduino nano. i am using the following code:
int pulses, A_SIG=0, B_SIG=1;
void setup(){
attachInterrupt(0, A_RISE, RISING);
attachInterrupt(1, B_RISE, RISING);
Serial.begin(115200);
}//setup
void loop(){
}
void A_RISE(){
detachInterrupt(0);
A_SIG=1;
if(B_SIG==0)
pulses++;//moving forward
if(B_SIG==1)
pulses--;//moving reverse
Serial.println(pulses);
attachInterrupt(0, A_FALL, FALLING);
}
void A_FALL(){
detachInterrupt(0);
A_SIG=0;
if(B_SIG==1)
pulses++;//moving forward
if(B_SIG==0)
pulses--;//moving reverse
Serial.println(pulses);
attachInterrupt(0, A_RISE, RISING);
}
void B_RISE(){
detachInterrupt(1);
B_SIG=1;
if(A_SIG==1)
pulses++;//moving forward
if(A_SIG==0)
pulses--;//moving reverse
Serial.println(pulses);
attachInterrupt(1, B_FALL, FALLING);
}
void B_FALL(){
detachInterrupt(1);
B_SIG=0;
if(A_SIG==0)
pulses++;//moving forward
if(A_SIG==1)
pulses--;//moving reverse
Serial.println(pulses);
attachInterrupt(1, B_RISE, RISING);
}
and, as i am a newbee, i am in trouble

when i start serial monitor i get some numbers coming in and when i turn the encoder also something is happening but not what i want. also numbers are changing when i touch the cables sometimes. so my guess is that i need some kind of pullup oder pulldown resistors somewhere. would someone be so nice and help me out here?
i connected the middle pin of the encoder to gnd on the arduino and the left and right pins to digital 2 and 3. and i do not know much about electronics.
have a nice day!