so far i have this yet i cannot figure out how to stop it from fading at the end of a run what am i missing
i cannot get it to work how you described am i missing sometingNot 100% sure I understand your questions. The 1000 is the delay factor. That code is the equivalent of delay(1000);
Code:delay(1000); is the same as unsigned long m; m=millis(); while(m+1000>millis());
Code:
int ledPin = 10;
unsigned long ledtime = 100;
unsigned long m;
void setup()
{
pinMode( 2, INPUT);
}
void loop()
{
m=millis();
static int fadeValue = 0;
if (digitalRead(2) == LOW)
{
if (fadeValue < 255)
{
fadeValue++;
analogWrite(ledPin, fadeValue);
while(m+1000>millis());
}
}
else
{
if (fadeValue > 5)
{ fadeValue--;
analogWrite(ledPin, fadeValue);
while(m+1000>millis());
}
}
}


