I am working with the 16F684, using the BoostC compiler and the MPLAB IDE. I am learning how to use the A/D converter. For now, I am reading in a voltage and turning on one bank of LEDs if it is less than a target value, and the other bank of LEDs if it is greater than the target value. Pretty simple stuff. The first part of the code seems to work and is int adc_result; //integer for storing 8 bit a/d result void main() { cmcon0 = 7; //turn off analog comparators ansel = 0b00001; //select AN0 (pin 13, RA0) as A/D input adcon0 = 0b00000001; //turn on A/D, select RA0/AN0 as input, don't start conversion adcon1 = 0b00110000; //select internal RC clock intcon = 0; //turn off interrupts t1con = 0; //turn off timer 1 porta = 0b111111; portc = 0b111111; trisa = 0b000001; //set port a as output, except RA0 trisc = 0b000000; //set port c as output while(1) { delay_ms(500); //delay between loops set_bit(adcon0,1); //start a/d conversion while (!test_bit(adcon0,1)); //wait for completion adc_result = adresh; //store a/d result The following code works . . . if(adc_result<0x0F) //if a/d count is below F then { porta = 0xFF; //turn on port a portc = 0x00; //turn off port c } if(0x0F<=adc_result) //if a/d count is above or equal to F then { porta = 0x00; //turn off port a portc = 0xFF; //turn on port c } but this code does not if(0x00<=adc_result<0x0F) //if a/d is below F then { porta = 0xFF; //turn on port a portc = 0x00; //turn off port c } //else if(0x0F<=adc_result<=0xFF) //if a/d is below F then { porta = 0x00; //turn off port a portc = 0xFF; //turn on port c } I'm sure I am overlooking something simple, but after a few hours of experimenting, I am stuck. I'd appreciate any help. Thanks. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist