Hello all,

This is my first PIC code in several years. Even back then, I only wrote a few simple programs and that will be obvious when you read my question.

I think that I'm OK with all the circuitry, and the main code isn't yet finished, but I would like for someone to help guide me with the math.

Let's assume that I have all the configurations correct.

I'll have a pot connected to AN2, which is configured for 8 bits. This should give me a value of 1 - 255 at AN2. I want to convert that range of numbers (1 - 255) into seconds and then use the new value in a variable for the PAUSE command. The code, I believe, should give me a range of 1 - 63 seconds. I just don't know how the decimal places will be handled and if the PAUSE command accepts non-whole numbers.

Thanks and regards,
Mitch


Code:
delayloop:
     ADCIN 2, adval                     ' read in value at AN2.
     IF adval <4 THEN                   ' make lowest value to be 4 which would equate
          adval = 4                     ' to a 1 second pause.
          delay = adval /4 * 1000       ' convert AD value of 1 - 255 into 1 - 63 second pause.
     ENDIF
     PAUSE delay                        ' pause from 1 - 63 seconds.