Jan-Erik, I am using a function that I pass a value to that represents the=20 number of seconds that I want the delay to last. I multiply this number=20 by ten in the for loop since there are 10 100ms interrupts for a second.=20 So if I pass 1 to the delay function, count will be tested for the=20 number 10. This is one second. If I call delay again and this time I=20 pass 15 to it, count will be tested for the number 150 and this is 15=20 seconds. Yes, I can use a while loop and I will rewrite it to do so as this=20 looks better but the for loop does the same thing. Now if I want to=20 change the delay based on the value of an ADC and controlled by the=20 position of a pot, I just have to correct the output of the ADC to=20 represent the position of the pot into something that the operator will=20 recognize as seconds. Then I just pass this number to the delay=20 function. So I can use the same function over and over rather than=20 calling two separate pieces of code. One that is hard wired for 1 second=20 and the other that can be controlled by the pot. But how do I reset the timer and where do I do this? Would I do it=20 before I call the delay function or inside the function just before I go=20 into the loop? Do I need anything more in the Interrupt routine than the=20 count variable? Thanks, rich! On 7/20/2014 5:50 AM, Jan-Erik Soderholm wrote: > Hi. > > It seems as you are mixing things up. > To make a delay in the code you have two options: > > 1. Use a timer interrupt. > 2. Use software timing loops. > > Your delay() function below will do nothing good. > What do you expect that it will do ?? > > The count variable that the interrupt code tries > to manage will be trashed by the delay function. > > Why would the two calls to delay(numberseconds) give > two different delays?? What is "numberseconds" and > where is it given a value? > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .