Uno Shutting Down (not heat related)

I am using an Arduino Uno R3 with a DS1307 RTC, driving 27 Super Bright clear LEDs (red, green, blue & yellow), of which there is a maximum of 24 lit any one time, for a period of one minute. The LEDs are being turned off and on at random each second.

I have checked the Uno board with an IR thermometer when the 24 LEDs are lit and the hottest spot, which is just behind the USB connection (not in use), is 29C max.

It has been running 24/7 for weeks without incident. When it shut down I immediately unplugged it and plugged it back in. Dead. Waited about 30 seconds, plugged it back in again, and it has been running for eight days now without incidence.

I originally posted this in the Installation and Troubleshooting forum because I really didn’t think it was the code. However, DrAzzy in that forum seems to thing it IS the code. So I have posted the code below.

It shut down automatically once before this. I was using millis() in the code at the time, so I rewrote the code eliminating the use of millis(). Now it has shut down again for no apparent reason.

Any ideas as to what to look at as a reason for the inexplicable shutdown and having to wait a few seconds before restarting, with no apparent harm?

/*   LED Clock
 *   by Dan Griffin 11/15
 *   
 *         12:53
 *   Hour Hour Min Min
 *   ---- ---- --- ---
 *    1   222  55  333
 *    1   222  55  333
 *    1   222  55  333
 *   
 *   Randomly light LEDs depicting the numeric value
 *   of the current time every second.
 *   
 *   Column anodes + (HIGH)
 *   Row cathodes -(LOW)
 */

  #include <Wire.h>                                        // RTC Clock.
  #include "RTClib.h"                                      // RTC Clock.
                                                           // LED arrays - [ON/OFF][Row][Column].
  int       intLed[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  const int conRow[27] = {2,3,4,2,3,4,2,3,4,2,3,4,2,3,4,2,3,4,2,3,4,2,3,4,2,3,4};
  const int conCol[27] = {5,5,5,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13,13};
  int       xCount;                                        // Temp counter for how many LEDs are set to ON.
  unsigned long startTime;                                 // Timer to insure 1 second each of ON then OFF.
  long      x;                                             // Temp val for random number generated.
  int       aTime[5] = {1,2,3,4};                          // Array of current time digits (12:34).
  int       iSec = 0;                                      // Temp val for change in seconds.
  RTC_DS1307 RTC;                                          // Create RTC object.

  // ------------------------------------------------------------------------------------------------
void setup() {
  pinMode( 2, OUTPUT);                                     // Rows (3)...
  pinMode( 3, OUTPUT);                                     // Anode (+).
  pinMode( 4, OUTPUT);

  pinMode( 5, OUTPUT);                                     // Colums (9)...
  pinMode( 6, OUTPUT);                                     // Cathode (-).
  pinMode( 7, OUTPUT);
  pinMode( 8, OUTPUT);
  pinMode( 9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);

  digitalWrite(2, LOW);                                    // Make sure all LEDs are OFF.
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  for(int i = 5; i < 27; i++) { digitalWrite(i, HIGH); }

  pinMode(16, OUTPUT);                                     // Pin A4 (- GND) for RTC.
  pinMode(17, OUTPUT);                                     // Pin A3 (+ 5v) for RTC.
  analogWrite(16,0);                                       // Set pin A4 LOW.
  analogWrite(17, 255);                                    // Set pin A3 HIGH.

  Serial.begin(9600);                                      // Only used to display error.
  // RTC.begin();                                             // Initialize RTC in 24 hour format.
  // RTC.adjust(DateTime(__DATE__, __TIME__));                // Sets RTC to your computer's time at the moment of upload to Uno.
}

  // ------------------------------------------------------------------------------------------------
void loop() {

  DateTime dTime = RTC.now();                              // Get the current time.
  if(dTime.second() != iSec) {
    iSec = dTime.second();                                 // Reset second temp val.
    for(int i = 0; i < 27; i++) { intLed[i] = 0; }         // Zero out the LED array.
    aTime[0] = char(int(dTime.hour() /10));                // Store the time digits.
    aTime[1] = char(int(dTime.hour() -(aTime[0] *10)));
    aTime[2] = char(int(dTime.minute() /10));
    aTime[3] = char(int(dTime.minute() -(aTime[2] *10)));

    // Hours (high).
    xCount = 0;                                            // Reset the counter.
    while(xCount < aTime[0]) {                             // Randomly set LED array to display "tens" of hours.
      x = random(0,3);
      if(intLed[x] == 0) {                                 // If we haven't already set this one...
        intLed[x] = 1;                                     // ...set it to ON.
        xCount++ ;                                         // Keep track of how many have been set.
      }
    }

    // Hours (low).
    xCount = 0;                                            // Reset the counter.
    while(xCount < aTime[1]) {                             // Randomly set LED array to display "ones" of hours.
      x = random(3,12);
      if(intLed[x] == 0) {                                 // If we haven't already set this one...
        intLed[x] = 1;                                     // ...set it to ON.
        xCount++ ;                                         // Keep track of how many have been set.
      }
    }

    // Minutes (high).
    xCount = 0;                                            // Reset the counter.
    while(xCount < aTime[2]) {                             // Randomly set LED array to display "tens" of minutes.
      x = random(12,18);
      if(intLed[x] == 0) {                                 // If we haven't already set this one...
        intLed[x] = 1;                                     // ...set it to ON.
        xCount++ ;                                         // Keep track of how many have been set.
      }
    }

    // Minutes (low).
    xCount = 0;                                            // Reset the counter.
    while(xCount < aTime[3]) {                             // Randomly set LED array to display "ones" of minutes.
      x = random(18,27);
      if(intLed[x] == 0) {                                 // If we haven't already set this one...
        intLed[x] = 1;                                     // ...set it to ON.
        xCount++ ;                                         // Keep track of how many have been set.
      }
    }
  }
  // ------------------------------------------------------ Light LEDs.
  for(int i = 0; i < 27; i++) {
    if(intLed[i] == 1) {                                   // IF we need to light this LED...
      digitalWrite(conRow[i], HIGH);                       // ...ground the row (cathode)...
      digitalWrite(conCol[i], LOW );                       // ...and power the col (anode).
      delay(1);                                            // (0 = dim / 2 = flicker)
      digitalWrite(conRow[i], LOW );                       // Turn it OFF.
      digitalWrite(conCol[i], HIGH);
    }
  }
}
  for(int i = 5; i < 27; i++) { digitalWrite(i, HIGH); }

Remind me, how many total pins does an Arduino Uno have?

  analogWrite(16,0);                                       // Set pin A4 LOW.
  analogWrite(17, 255);                                    // Set pin A3 HIGH.

Are 16 and 17 PWM pins?

Bending the limits?
What is done to ensure no single port current>max? and no PORTx current> maxPORT-current?

WTH are you doing here?

 pinMode(17, OUTPUT);                                     // Pin A3 (+ 5v) for RTC.
//...
  analogWrite(17, 255);                                    // Set pin A3 HIGH.

I think we need to see a circuit diagram! How are you running 27 Super brite Led's on a 20 pin Uno?

Mark

1: There are 18 pins on the digital side, and 13 on the analog side. Line 50 that you highlighted is indeed logically curious CodingBadly (how apropos). I will correct that to

for(int i = 5; i < 13; i++) { digitalWrite(i, HIGH); }

2 & 4: Are 16 and 17 PWM pins? I don’t know(?) And I can’t find where I got the code associated with the RTC in my code. Obviously not from the RTC Library examples on this site. Are those two lines of code totally unnecessary?

3: Nothing. I didn’t know anything should or could be done (in code). I just read that each pin SHOULD typically provide 20mA with 50mA causing permanent damage. However, this setup will be driving a max of 9 LEDs at 20mA each. So why hasn’t it burned out or otherwise failed in the first day.

Every day it reaches a point (12:59) with 18 LEDs lit for a full minute, and 18:59 with 23 LEDs lit for a full minute. It’s a matrix setup with the rows (3) being power and the columns (9) as ground.

In retrospect, setting all the anodes LOW and all cathodes HIGH in order to set all LEDs OFF is probably not the best solution.

On the other hand, it has been working perfectly for weeks without issue and at a max temp of 29C.

So, where does that leave me?

There are 18 pins on the digital side, and 13 on the analog side.

What do you mean by digital side/analog side?

The are no "sides" and on an Uno there are 14 digital I/O pins and 6 analog inputs which can also be used as digital I/O

Mark

One side of the board is lined with pins that are labeled “DIGITAL (PWM~)” and the other side is labeled “POWER ANALOG IN”.

I whipped up a circuit diagram (attached) as quick as I could.

There are no current limiting resistors on your LEDs. That is a very bad thing.

Sorry aarg. Actually there are (was too hasty with diag) 150's.

MavenScout:
Sorry aarg. Actually there are (was too hasty with diag) 150's.

Please come back with a complete diagram (the entire system) and some photos.

Here are the updated diam and pic.

Maybe I should mention that this is the first electronics project I’ve done since assembling a crystal radio when I was 7… I’m 65. Not an excuse, just a fact. Please be kind :slight_smile:

Actually, that's pretty good for a first project. We've seen a lot worse here.

Have you tried powering it from the USB port, instead of the barrel jack?

Yes, but not long term. All of the time spent prototyping, testing and assembly it was powered through the USB port. Interesting that you should mention this. The max temp I'm getting from the board is just behind the USB port (while plugged into the barrel jack). Yet it's only 29C.

Well, when you run from the barrel jack, the onboard voltage regulator is used. It might be overloaded. I generally use a 5V@2.0A USB power adapter for similar projects.

If the VR is overloaded, wouldn't it result in a high temp? This thing reaches it's highest current draw twice a day, and it ran for about a month before the first shut down. I was using millis() then, so I adjusted the code to work without it, and it ran for a few more weeks before it shut down again. Each time, after about 30 seconds of being unplugged it started right up and ran flawlessly.

Might you be suspecting a defective VR? I have a second UNO that I can switch out and see what happens, but it could easily be another month or two to see if that's it. Unless you know of an easy way to check the VR with a VOM. I have a Fluke 115 that I am learning to use.

Most VR's have internal thermal limiting. What voltage are you feeding to the barrel jack?

Switching AC/DC Power Adapter 9v 1A that came in the Arduino UNO Starter Kit from Adafruit.

IR thermometer will average over an area - carefully test the regulator package
itself with a finger (carefully because it might be 150C).