DelayMicroseconds(0) caused unwanted flashing in the LED so don't use values lower than 3.
void smoothblink() {
for (int i=10;i<600;i++) {
digitalWrite(ledPin, HIGH);
delayMicroseconds(i);
digitalWrite(ledPin, LOW);
delayMicroseconds(600-i);
}
for (int i=10;i<600;i++) {
digitalWrite(ledPin, HIGH);
delayMicroseconds(600-i);
digitalWrite(ledPin, LOW);
delayMicroseconds(i);
}
delay(100); // led off for a while
}
No comments:
Post a Comment