I have a Piher 04-CI-11 rotary encoder 30 detents/15 pulses two bit. The code (below) that I have scraped up works, with one annoying flaw, it only ever counts in two's either 1,3,5,7 etc or 2,4,6,8. Now other than rewriting the code completely is there an adjustment I can make to the maths? Or would just changing the size of the knob help? The encoder code is -- // A terminal of encoder is connected to PortA:1, B to PortA:0 void getenc() { unsigned char new_enc_state; unsigned char temp_enc_state; new_enc_state=PORTA; new_enc_state&=0x03; //get bottom two bits temp_enc_state=new_enc_state; temp_enc_state^=old_enc_state; if (temp_enc_state==0) { enc_state=0; //No change return; } old_enc_state=old_enc_state<<1; //rotate old bit 0 to bit 1 old_enc_state^=new_enc_state; //which bit changed? if (old_enc_state&=(1< 99 construct if (lmenu==2) //set under humidity trip point { getenc(); if(enc_state==1) //encoder moved CW { #asmline incf trip+0,F ; increment struct trip.hummidity } if(enc_state== -1) //encoder moved CCW { #asmline decf trip+0,F ;decrement trip.humidity } #asm movf trip+0,W addlw 155 ;255-100 we are testing for range 1 to 100 addlw 100 ;(max range[100] - min range[1])+1 movf trip+0,W ;this is needed due to Wiz-C internal routines that deduct one from W for function calls. btfss STATUS,C #asmend trip.humidity=50; display1(trip.humidity,3); //send to display format 3 digits wide As you can see only being able to set temperature and humidity trip points in odd or even numbers, is not quite what is needed. Thanks for any advice. Colin -- cdb, cdb@barnard.name on 31/03/2002 -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics