trying to use millis()
The problem here is that the variables you declare in your function are not static. The rest of the code works as expected.
Where you declare the variables at the beginning of your function is correct. There is only one variable in question though as it is the cause of the error you are seeing.
What you need to do is change the variable
unsigned long pMillis;

to
static unsigned long pMillis = 0;

By not having the pMillis as a static variable, each time the function is called the value of pMillis is undefined, which means it is unpredictable whether  (cMillis - pMillis &gt; interval) will be true or false. But with the static declaration the Arduino knows to keep the previous value for the next time you call the function.
An excerpt from Wikipedia:

In computer programming, a static variable is a variable that has been allocated statically—whose lifetime or &quot;extent&quot; extends across the entire run of the program....
A static local variable is different from a local variable. It is initialized only once no matter how many times that function in which it resides is called.