Best practice LED and buzzer signals for setup and loop?

I want to add some acoustical and optical signals when the Arduino setup starts, ends, and when the loop is running.

I have something in mind like flashing a red LED 1 time when setup starts and 2 times when it ends. And maybe also a similar buzzer signal.

And then for the loop maybe a green LED flashing every x loops.

The idea is to see the program works correct. I also think about using this because I have to make sure one sensor is not moved in setup for a few seconds. So I would know i.e. that after 1 flash and a beep I should not move it and after 2 flashes and 2 beeps all is done.

I know how to implement this, that is not difficult.

My question is if there is a standard procedure like this. Maybe a best practice which is used by many developers to show that the program works correct.

Thanks for any ideas.

In setup() just use delay() to turn the LED off after a short while at the top, and just do that twice at the bottom. Code that long hand, repeating a few lines, or use a "for" if you feel the urge.

In loop(), rather than blinking each time thru loop() which is really fast, use blink without delay to provide a flash every say 500ms as a kind of proof of life. That's what I do, almost as a matter of course, to prove no other code is doing any blocking.

edit: I don't mean to put that across as best practice, just my practice.

ardy_guy:
In loop(), rather than blinking each time thru loop() which is really fast, use blink without delay to provide a flash every say 500ms as a kind of proof of life. That's what I do, almost as a matter of course, to prove no other code is doing any blocking.

edit: I don't mean to put that across as best practice, just my practice.

I've seen this on early computer controlled production equipment. It was usually called a "heartbeat monitor", or something similar.

nixie:
It was usually called a "heartbeat monitor", or something similar.

Yeah I usually put it in a function called heartBeat() or pulse() or whatever. See #18 here, where I called it heartbeat() to flash the cursor in a time display.

Hi Edgar,

To answer your question - yes, this is a common thing to do. Rather than flashing the “calibration” led, you could simply leave it on unless you think the program may fail and you’re looking for an indicator.

It is also common to include a heartbeat LED that flashes at 1 Hz using the “blink without delay” approach.

Pat.