loop();activity indicator

A quick tip...




Ohne das inzwischen nachgereichte Bild kann man zu Deinem Text nicht mehr sagen.

  // Blink at 2 Hz unless something delays loop() more than 250 milliseconds
  digitalWrite(LED_BUILTIN, (millis()/250) & 1);
  // Blink based on the repeat rate of loop()
  static unsigned long cyclecount;
  digitalWrite(LED_BUILTIN, (cyclecount/100) & 1);

SORRY, initial post didn’t carry the photo originally, because it seems I can’t upload images from my iPad..

The thread was going to be that devs should consider adding two LEDS to their projects, maintained in loop() as noted above
Yes, a millis() timer can be used to tick the green ‘Activity’ LED, possibly with a short 50ms ON period, and something like 800ms OFF time. (less battery draw)

The second red ‘Attention’ LED is turned on/off if there is a code condition that warrants attention. A more elaborate scheme uses a blink count of the red LED to denote different types of issue.

When you’ve got enough time, you cam make the ‘Activity’ LED with a breathing appearance using PWM.

Next time I’m back at my desktop, I’ll fix up the image, and post some code to plug into your project.

Sometime in the early 1980's I discovered that customers using the company's system based on Data General mini-computers did not have an easy way to determine if a very long-running job was actually running or not. Once they waited a whole weekend for a job to finish that had died very early-on.
So we had to add something they could see that was always changing. Usually a record count or something similar. I called it a "passifier".
I had to do something similar for a long-running Arduino program. It had a LCD display so I added a blinking period to one corner of the display. Time period was about 15 seconds. Worked well.

So we had to add something they could see that was always changing. Usually a record count or something similar. I called it a "passifier".

A less infantilizing name would be "activity indicator". Calling it a pacifier makes it seem like just something pointless to keep a baby occupied, but feedback is an extremely important part of human factors design.

Nah, old timers don’t need no stinkin’ feedback, adding it was a form pacification.

See old timers knew everything was running fine, just leave it alone and it will finish soon. They had a sixth sense allowing them to basically smell when things were right and not right.


Waiting for a slow or stalled program was often the only time we had to run and get coffee.

Heartbeat LED, Pin 13.... :slight_smile:

Yep, on a standard product board, but in custom boards - as you know, there are a lot more states you may want to communicate.

(Of course a ‘595 with 8 LEDs offers some more possibilities, or a NAX7219 with whatever is connected!)

(P.S. I use the onboard LED every time tine as a heartbeat indicator, but most of my projects aren’t built on standard Arduino boards nowadays.)

I started doing something similar to all my projects recently. At the end of setup() they flash a pattern to let me know the program is ready to go. As an added bonus it looks cool too.

I like the idea of activity lights. That's something I miss on new computers, there's not flashing HDD light to tell you if the machine is still busy churning away or if it's crashed.

I have done a number of commercial projects where I have a set of header pins that I can plug an LED array into when trouble shooting or program upgrading.

An SMD MCP3008 on the I2C doesn't take much room on a PCB, and I've had an idea to mount if possible an 18pin DIL socket over the top so not a great deal of PCB tracks required. (Must investigate that..)

If you have program space place a header for I2C 16x2 LCD display. An extra pin to tell the software if the LCD is connected or not.

All this of course depends on program and hardware complexity.
Horses for courses.

Tom.... :slight_smile:

An OLED doesn't take up much space and can be used to display any status messages you like. Probably needs a time out so that it is off most of the time and doesn't suffer burn in from being on all the time.

Yeah, i do use a 1-wire LCD interface* on those projects, and an R2R ladder for pushbuttons when needed, but if space, power are considerations, a lot can be shown with 1 or 2 LEDs.

The loop() heartbeat is ‘important on devices that you aren’t monitoring all the time.

  • the 1-wire LCD is really simple and clever, you shift the CLK bit out before the data bits, and when the SR overflows, the contents of the SR are latched into the LCD !

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