squid08:
WizenedEE:
That's about what I guessed. Try implementing what I described in the last two paragraphs of my post and come back with questions about how to do soThis is my first attempt at the code.
How does it look?
That looks really good! Just a few tips and it should work great. I modified it a little
void loop () {
static unsigned long startButtonPressTime;
static byte lastButtonState = LOW;
int pwr;
byte buttonState = digitalRead(button);
if (buttonState == HIGH) {
if (lastButtonState = LOW) {
startButtonPressTime = millis();
}
else {
pwr = map(millis() - startButtonPressTime, 0, 1000, 0, 255); // after 1 second give full pwm output
}
}
analogWrite(3, pwr);
lastButtonState = buttonState;
}