Does a delay inside an if() pause loop?

Just getting back into Arduino and puzzling over this probably basic point.

In my main loop I have an if. Its condition is met and an LED switched on, followed by a delay of 4 seconds, then the end of the if and the loop. But the LED (and its 220 ohm resistor) appears to be getting only about 2.5V. It’s as if it is being switched on and off rapidly. But how can that be happening? Surely the loop should not repeat until the LED goes off?

Terry

That can happen because of your code.
Paul

have you set pinMode?
show your code.

1 Like

Oh and use code tags when posting your code.

Hello
Either, you use the BWOD example located inside the IDE and make with this sketch some mods as training ,
or post you sketch well formated in code tags.

Duh! Thanks, no I had carelessly failed to set it. Discovered just before returning here to report so.

Could not attach code as I’m working in shed on my old PC with no internet, and posting from my iPad.

Let me know if anyone still like to see the code and I’ll do so when I get back to the house PC.

Spent most of the day baffled by this!

Terry

it's not necessary any more. Imho the solution is clear.

Talking about solution...
mark the above answer as solution,
If you want you can give hearts to people who helped you...

1 Like

I know the feeling :slight_smile: Happens to all of us at some point. Or several points...

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.