Is it possible to let a LED blink, for example 5 times, with an Arduino? Should I use a for loop?
Something like this works in setup, but it will run continuously in the void loop, so my LED keeps blinking.
for (int i = 0; i <= 5; i++) {
led HIGH
delay(500);
led LOW
delay(500);
}
Also, the blink sequence has to be triggered, and have a reset after it is done.
The complete code is too big to share, but it runs a bit like the following:
There is a "bankValue", it is filled by a user, and counts back to zero.
If it's zero, then blink 5 times.
After the blink, the LEDs are off.
The sketch is waiting for a new user, who will fill the bankValue again and the LED blink should again be initiated.
new user, who will fill the bankValue. please elaborate...loop()repeats tens of thousands of times per second (if there are no delays, of course) .... to run the code only once, use a flag such assetup () {bool xyz = true;}... then you check the state of the flagloop () { if (xyz) { blink leds; do other stuff; xyz = false; } }... this will run only once, unless there is some code inloop()that sets the flag again