Paul Duffy wrote: > adcon0 = 0b00000001; //turn on A/D, select AN0 as You should document what each bit does. Aren't there bits in there for right/left justify and Vref too? > input, don't start conversion delay_ms(10); > //delay each time through loop, set_bit(adcon0,1); > //start a/d conversion while (!test_bit(adcon0,1)); > //wait for completion on = adresh; > //store on_time - AN0 if(on==0)on = on+1; > //ensures on_time !=0 > > adcon0 = 0b00000101; //Change the input to AN1, > don't start conversion delay_ms(10); > //delay each time through loop, set_bit(adcon0,1); > //start a/d conversion while (!test_bit(adcon0,1)); > //wait for completion off = adresh; > //store off_time - AN1 if(off==0)off = off+1; > //ensures off_time !=0 } There is good reason this doesn't work. If you hadn't formatted your message so that it looks like a mess when I try to reply, I would go into more detail. Learn not to put tabs in code you ask others to look at. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist