Thanks for your assistance, I revised the code as you recommended from what I understood. I don't know if I didn't do something properly and it seems to only give 0's on serial monitor.
const int ledPin = 13;
const int potPin = 7;
int potInterval = 0;
int potDuration = 0;
int fade = 0;
int fadeIncrement = 5;
long preTime = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(potPin, INPUT);
Serial.begin(9600);
}
void loop()
{
unsigned long time = millis();
potInterval = analogRead(potPin);
if(time - preTime > potInterval)
{
preTime = time;
if(fade <= 0)
{
fadeIncrement +=5;
}
if(fade >= 255)
{
fadeIncrement -=5;
}
Serial.println(fade);
}
fade = fadeIncrement;
analogWrite(ledPin, fade);
}