Hi guys. I'm having a real problem with a seemingly simple sketch and I've been working for a long time to try and find a solution. I have little to no coding knowledge and am very new to arduino and coding.
Problem;
the basic sketches that are built in allow the fade program to run just fine.
But when i try to add a delay after the led goes back off, I can only ever achieve adding a delay between
increments of brightness.
to be clear, i want to control how long the led stays off before it starts to brighten again each time.
any assistance would be greatly appreciated. I look forward to hearing from you all and learning more.
int ledPin = 9; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// ---Try putting your delay here---
}