Built-in LED flashes when NANO stops working

I built a digital clock that is controlled by a standard NANO. It worked fine for about a month, then the display started going blank. Then it would come back on. I'm not sure of the time periods. I would look and it was on, the next time I looked it would be off. Anyway, I noticed that when the clock turned off, the red built-in LED on the NANO was blinking. I assume this was to indicate some problem with the NANO, like an error code or something. Can anyone tell me what it means?

Does your sketch use Nano pin 13? Post a wiring diagram and the sketch.

I looked at schematic for the Arduino Nano (V3.3 on Arduino.cc) and found that it has 4 different LEDs on the board. There are a green power LED, a yellow built-in (pin 13), a green TX LED, and a red RX LED. So, if your board has those LED colors, then your clock appears to be receiving data from the USB port when the display is off.

This information only confuses me further about your clock problem. Without knowing anything about the clock wiring schematic, the Arduino sketch running, or the USB activity; I am only able to sympathize with you for the clock malfunctioning.

1 Like

xfpd: My sketch does not use pin 13. I have a wiring diagram in EasyEDA because I had a PCB made for this project. But I've never posted a wiring diagram or sketch before and I don't know how to do that. If you could inform me or point me to a help file, I would appreciate it very much.

For the sketch:

  1. Format your sketch in the IDE (CTRL-T)
  2. Copy the sketch (CTRL-A, CTRL-C)
  3. Open a reply/message
  4. Click the < CODE > "button" in the message/text box.
  5. Paste your code where you see type or paste code here

For the drawing:

  1. Make the drawing into an image
  2. In the message box click the UPARROW button next to the < CODE > button
  3. Select your drawing.

** you read, were tested, and agreed to this as you "read" through the forum indoctrination.

xfpd: The old adage seems to be true that 'if you don't use it, you lose it'. I guess I should have read that indoctrination again to refresh my memory. My apologies.
I'll briefly explain this project to help you understand what's going on. This is a large digital clock with each digit approx. 3" x 6". The segment LEDs are actually a 3 LED strip cut from a 12 volt LED strip light, which has a built-in resistor, which is why you don't see LED resistors on the drawing. According to my meter, each 3 LED strip draws 0.046 amps. It is powered by a 700mA 12VDC plug in adapter. I didn't add the ability to change the time using a remote until recently, so it wasn't built into the PCB, I simply soldered wires to the appropriate points. You can see where I edited the drawing for this by the slightly heavier green lines.
I would expect that the built-in LED that starts flashing when the NANO stops working means something that I could use to help pinpoint the problem, but I can't find documentation on it anywhere.


```cpp
/* The left pin of the IR receiver connects to NANO D2. The IR center pin to ground and the right pin to 5V
 *  The mosfet pins, 1,2 3, left to right are Gate, Drain and Source. Connect the Gate to NANO D7, the Source to ground
 *  and the drain to the colon cathode wire.
 *  The remote is an extra we have thats an LG AK873975722. Pressing the 'OK' button once puts the clock into time set mode 
 *  and the colon will flash while in this mode. While in this mode, pressing the 'up arrow' will increase the hour; pressing 
 *  the 'down arrow' will decrease the hour; pressing the 'right arrow' will increase the minutes; pressing the 'left arrow' will
 *  decrease the minutes. Pressing the 'OK' button again takes it out of clockSetMode and the colon stops blinking. Pressing any
 *  buttons (other than 'OK' button) while not in clock set mode does nothing. That is all the remote will currently do.
 */
#include <IRremote.h>
#include "LedControl.h"
#include <Wire.h>  //Library for SPI communication
#include <binary.h>
#include <DS3231.h>  //Library for RTC module

#define IR_RECEIVE_PIN 2  //Set the IRreceiver on pin 2 on the Arduino
#define DS3231_I2C_ADDRESS 0x68

#define colonPin 7  //connects to Mosfet gate
LedControl lc = LedControl(10, 12, 11, 1);
unsigned long delaytime = 100;

DS3231 RTC;  //Declare object RTC for class DS3231
int h;       //Variable declared for hour
int hh;
int m;  //Variable declared for minute
int thousands;
int hundreds;
int tens;
int unit;
bool h24;
bool h12;
bool PM;
int sec = 0;
int mnt = 0;
int wkd = 0;
int dt = 0;
int mo = 0;
int yr = 0;
unsigned long flshStrt = 0;  //for flashing colon while in clksetmode
unsigned long flshStop = 0;
bool colonOn = true;
bool clkSetMode = false;

void setup() {
  Wire.begin();
  Serial.begin(9600);
  IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK);
  lc.shutdown(0, false);
  /* Set the brightness to a high value */
  lc.setIntensity(0, 15);
  lc.clearDisplay(0);
  pinMode(colonPin, OUTPUT);
  //The time setting code below is commented out after original upload
  //so as to not reset the time if the unit loses power
  //Serial.println("Setting the time");
  //RTC.setYear(24);
  //RTC.setMonth(4);
  //RTC.setDate(4);
  //RTC.setDoW(5);
  //RTC.setHour(10);
  //RTC.setMinute(53);
  //RTC.setSecond(15);
  //Serial.println("Time has been set!");

  digitalWrite(colonPin, HIGH);
}

void loop() {
  //check for button push of remote
  if (IrReceiver.decode()) {
    unsigned long irCode = IrReceiver.decodedIRData.decodedRawData;
    if (irCode != 0) {       //the remote sends out a 0 if the button is pushed too long - ignore
      IrReceiver.resume();   // Receive the next value
      handleIRCode(irCode);  //call procedure to handle a button push
    } else {
      IrReceiver.resume();  // Receive the next value
    }
  }
  if (clkSetMode == true) {
    if (millis() < flshStrt) {  //in case the millis() was reset to 0 after flshStrt was set
      flshStrt = millis();      //start over
      flshStop = flshStrt + 250;
    }
    if (millis() >= flshStop) {  //flash the colon
      if (colonOn == true) {
        digitalWrite(colonPin, LOW);
        colonOn = false;
        flshStrt = millis();
        flshStop = flshStrt + 250;
      } else {
        digitalWrite(colonPin, HIGH);
        colonOn = true;
        flshStrt = millis();
        flshStop = flshStrt + 250;
      }
    }
  }
  //code to display the time starts here
  byte num;
  int hh = RTC.getHour(h12, PM);  //To get the Hour
  if (hh > 12)                    //change to 12 hour format
  {
    h = hh - 12;
  } else {
    h = hh;
  }
  if (hh == 0)  //midnight shows as 0
  {
    h = 12;
  }
  int m = RTC.getMinute();             //TO get the minute
  int number = h * 100 + m;            //Converts hour and minute in 4-digit
  int thousands = number / 1000 % 10;  //Getting thousands digit from the 4 digit
  int hundreds = number / 100 % 10;    //Getting hundreds digit from 4 digit
  int tens = number / 10 % 10;         //Getting tens digit from 4-digit
  int unit = number % 10;              //Getting last digit from 4-digit
  int t = unit;
  int u = tens;
  int v = hundreds;
  int w = thousands;
  num = getBinForDec(t);  //return the binary equivelant for the decimal
  lc.setRow(0, 3, num);   //send info for the 4th digit
  delay(delaytime);
  num = getBinForDec(u);
  lc.setRow(0, 2, num);  //send info for the 3rd digit
  delay(delaytime);
  num = getBinForDec(v);
  lc.setRow(0, 1, num);  //send info for the 2nd digit
  delay(delaytime);
  if (w == 0) {  //remove the leading zero if hour is a single digit
    num = B00000000;
    lc.setRow(0, 0, num);  //send info for the 1st digit
    delay(delaytime);
  } else {
    num = getBinForDec(w);
    lc.setRow(0, 0, num);  //send info for the 1st digit
    delay(delaytime);
  }
}

byte getBinForDec(int dec) {  //function to convert decimal to binary
  byte result;
  switch (dec) {
    case 0:
      result = B01111110;
      return result;
      break;
    case 1:
      result = B00110000;
      return result;
      break;
    case 2:
      result = B01101101;
      return result;
      break;
    case 3:
      result = B01111001;
      return result;
      break;
    case 4:
      result = B00110011;
      return result;
      break;
    case 5:
      result = B01011011;
      return result;
      break;
    case 6:
      result = B01011111;
      return result;
      break;
    case 7:
      result = B01110000;
      return result;
      break;
    case 8:
      result = B01111111;
      return result;
      break;
    case 9:
      result = B01111011;
      return result;
      break;
  }
}

void handleIRCode(unsigned long code) {  //procedure to handle remote button push
  if (code == 3141860100) {              //OK button for clkSetMode
    if (clkSetMode == true) {
      clkSetMode = false;
      digitalWrite(colonPin, HIGH);  //reset colon to stay on since leaving clock set mode
      colonOn = true;
    } else {
      clkSetMode = true;
      digitalWrite(colonPin, LOW);
      colonOn = false;
      flshStrt = millis();  //start the timer for flashing the colon
      flshStop = flshStrt + 250;
    }
  }
  if (clkSetMode == true) {  //only run code below if in clock set mode
    switch (code) {
      case 3208706820:       //up arrow, increment hour
        retrieveDateTime();  //procedure to set clock variables
        h = ++h;
        setTimeDate();  //procedure to set clock time using variables
        break;
      case 3191995140:  //down arrow, decrement hour
        retrieveDateTime();
        h = --h;
        setTimeDate();
        break;
      case 4177984260:  //right arrow, increment minute
        retrieveDateTime();
        mnt = ++mnt;
        setTimeDate();
        break;
      case 4161272580:  //left arrow, decrement minute
        retrieveDateTime();
        mnt = --mnt;
        setTimeDate();
        break;
    }
  }
}

void retrieveDateTime() {  //procedure to set clock time variables
  sec = RTC.getSecond();
  mnt = RTC.getMinute();
  h = RTC.getHour(h12, PM);
  wkd = RTC.getDoW();
  dt = RTC.getDate();
  mo = RTC.getMonth(CenturyBit);
  yr = RTC.getYear();
}

void setTimeDate() {  //procedure to set time using variables
  RTC.setYear(yr);
  RTC.setMonth(mo);
  RTC.setDate(dt);
  RTC.setDoW(wkd);
  RTC.setHour(h);
  RTC.setMinute(mnt);
  RTC.setSecond(sec);
}

dre1

Classic Nano has no such feature.

I can't immediately see any reason why your onboard led would be flashing. Is it possible that the IRremote library is flashing it?

This never happens. How do you determine "stops working?"

I guess that's a possibility. I could comment out the code for the remote and the reference to the IRRemote library and see if that affects it. But my problem was that the NANO stops working, not that the onboard LED was flashing. I was hoping that the flashing was a code of sorts indicating a specific problem, which evidently it isn't.
I've tried replacing the NANO and the other two chips on the chance they were bad, but it didn't help. I haven't replaced the DS3231 module because it seems to be keeping time properly. When it finally starts working after shutting off, it has the correct time. So, I assume it's not the problem, but I don't know. Other than the Mosfets, it is the only component I haven't replaced.
It makes me think it's an overheating problem, the way it works for a while, turns off and then turns back on after a period of time. But nothing feels hot. And, I can unplug the power and immediately plug it back in and it starts working immediately, which it likely wouldn't if something was overheating.

xfpd: All the digits are off. The colon is still on, but it isn't controlled by the Arduino.

The Arduino is constantly running. Even if you have a while(1) or void loop() {}

DIO13 is PORTB bit 7. I wonder if other bits in PORTB are sourcing a lot of current.

If the Arduino is constantly running, it made me wonder - wouldn't there have to be code to turn off the digits that were turned on by the code? How else would they turn off?

An anode pulled high (while the cathode is low) or a cathode pulled low (while the anode is high). Sort of a brown-out condition.

Is the renegade LED_BUILTIN toggling at a measurable rate? (I just re-read post 1... "When the clock is turned off")

Maybe I'll try to measure how much power the clock as a unit is using, which would vary depending on which segments were lit up. Might be that I could detect a problem there.

I haven't expressly timed it, but it seems like it's about 2 to 3 times a second. One other thing I noted, when the clock is working, I read a small voltage at the MAX7219 data in pin (pin 1). When it's not working, I no longer read that voltage. That's part of what made me think the Arduino quit working.

What about the IR receiver?

No, not the IR receiver. I've got to run some errands, but when I get back I want to test a couple more things, like total current draw. But I've got a couple questions. Since this is multiplexing very quickly between the 4 digits, how accurate will my current reading be? Will it measure the highest draw or an average or will my jump all over the place? And I thought about monitoring the output on the serial monitor to see if something changes when it turns off. But that would probably be a waste of time, wouldn't it? Because the code will run properly all the time and wouldn't indicate a possible signal output problem?

Never mind - forget that previous post. If I test the current draw at 3:33 or 4:44 I should get a fairly steady reading.

: ) couldn't be. : )

Only one way to know.

I would remove the Arduino and test it stand-alone with a blink sketch that uses the LED_BUILTIN... and then upload your full sketch while in stand-alone mode. Look to eliminate components by proving they work in incremental steps.