'for' loop inside 'if 'condition

hi everyone, I'm Newbie to the arduino world. I need some help with the program.
I need to switch ON four outputs in sequence one by one with a time delay for every output based on a single input(HIGH)..
I used If condition with a for loop , and its working. But the problem is the outputs not getting off immediately based on input state. Once started , its getting off only after completing sequence. I want the outputs to be stopped right away and wait for input. Please help, thank you.

if (X == HIGH ){
for (int Pin = A; Pin < E; Pin++) {
pinMode(Pin, OUTPUT);
digitalWrite(Pin, HIGH);
delay(timer);
digitalWrite(Pin, LOW);}}

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

hary666:
hi everyone, I'm Newbie to the arduino world. I need some help with the program.
I need to switch ON four outputs in sequence one by one with a time delay for every output based on a single input(HIGH)..
I used If condition with a for loop , and its working. But the problem is the outputs not getting off immediately based on input state. Once started , its getting off only after completing sequence. I want the outputs to be stopped right away and wait for input. Please help, thank you.

if (X == HIGH ){
for (int Pin = A; Pin < E; Pin++) {
pinMode(Pin, OUTPUT);
digitalWrite(Pin, HIGH);
delay(timer);
digitalWrite(Pin, LOW);}}

Try this post

if (X == HIGH ){
  for (int Pin = A; Pin < E; Pin++) {
    pinMode(Pin, OUTPUT);
    digitalWrite(Pin, HIGH);
    delay(timer);
    digitalWrite(Pin, LOW);
    delay(timer);
}}

There should be a delay for both High and low

Yeah add some delay in your for loop and it will work fine.