Here is a snippet I've used successfully using 'C'. It does suffer from false readings if the knob is turned to fast, but for the use I needed that wasn't a problem. //Encoder 'A' output on PortA,1 'B' output on PortA,0. Port pins //pulled low via 2*10K resistors void getenc() { //encoder channel B=0 if (!bRA0) old_enc_state=1; //show that we've got here if ((bRA0) && (old_enc_state)) //if Channel B now =1 { if (bRA1) //if encoder now =11 ,we're going CW so increment { enc_state=1; //set enc_state to show old_enc_state=0; //set to zero, wait until this event again } if((!bRA1) && (old_enc_state)) //Channel A=0 and B =1 going CCW { enc_state=-1; old_enc_state=0; } } else { enc_state=0; //encoder hasn't moved } Colin -- cdb, bodgy1@optusnet.com.au on 15.08.2003 I have always been a few Dendrites short of an Axon and believe me it shows. Light travels faster than sound. That's why some people appear bright until they speak! -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads