Hello,
I stuck with the millis counter, which I want to use instead of the Dealy (20) on the end.
I searched the Web and the Forum.
I hope somebody can help me to replace the "Delay" on the end.
I'll try again.
int reading1 = digitalRead(btnPinS1);
if (reading1 != lastBtnStateS1)
{
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
if (reading1 != btnStateS1)
{
btnStateS1 = reading1;
if (btnStateS1 == HIGH)
{
ledState1 = !ledState1;
}
}
}
if (ledState1 == HIGH && pwmC1 >= 0 && pwmC1 <= 254)
{
pwmC1 = pwmC1 +5;
delay(20);
}
if (ledState1 == LOW && pwmC1 >= 1 && pwmC1 <= 256)
{
pwmC1 = pwmC1 -5;
delay(20);
}