Help :)

Hi!

I'm new to Arduino and making a program to make a LED blink:

int led = 13;

void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(900);
digitalWrite(led, HIGH);
delay(800);
digitalWrite(led, LOW);
delay(700);
digitalWrite(led, HIGH);
delay(600);
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(400);
digitalWrite(led, LOW);
delay(300);
digitalWrite(led, HIGH);
delay(200);
digitalWrite(led, LOW);
delay (3000);

}

is there a way to subtract 100 from delay every time the program is "finish"?

birkeve:
is there a way to subtract 100 from delay every time the program is "finish"?

Yes. Learn about the "for loop" statement: https://www.arduino.cc/en/Reference/For
What do you want to happen when the delay is less than 100?

The program never finishes, because loop gets called repeatedly.
You can have a simple variable to provide your delay, and subtract 100 each time through loop, but it's going to go negative or wrap very quickly

Please rememeber to use code tags when posting code, and change the title of this thread.

Welcome to the Forum. First, please read Nick Gammon's two posts at the top of this Forum for guidelines on posting here, especially the use of code tags ("</>"). Second, of course you can alter the delay value. Something like this:

int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
}

void loop() {
  static int pause = 1000;
  
  digitalWrite(led, HIGH);
  delay(pause);
  digitalWrite(led, LOW);
  pause -= 100;
  delay(pause);
  pause -= 100;
  if (pause < 200) 
    pause = 1000;
    
  delay(3000);
}

Maybe like this:

byte led = 13; 
int pause = 1000;
byte ledState = 1;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
ledState = 1;
  digitalWrite(led, ledState);
while (pause >=200){
  delay(pause);
  digitalWrite(led, (1-ledState)); // toggle output level
pause = pause - 100; // decrease delay time
}
pause = 1000; // reset led delay time
  delay (3000); 

}

johnwasser:
Yes. Learn about the "for loop" statement: https://www.arduino.cc/en/Reference/For
What do you want to happen when the delay is less than 100?

Yes, stay with for .. loop before doing "while".
For loop conditions/ variables are NOT limited to ONE.
You can do BOTH blink the LED and decrement the delay in same for loop.
And get in the habit to call digital variables true or false or 1 and 0. complement them ( to invert them) (!) before confusing the issue with other ways to switch from true to false and vise verse. KISS