Issue: Arduino lockup? (possibly power issues)

Ok, I've been working on a simple LED function like script (I guess a basic library, just calls different functions for blinking, sequencing, and pulsing/fading).

All of the code works, but after 30 seconds of being on (or less) all of the LEDs stop blinking/sequencing/pulsing/fading, but the power light stays on, and if I wait, it does eventually come back on.

My guess would be it's going into an over/under voltage/amperage protection mode, and resets when it gets good/stable values, but it's not a great thing to have to work through.

I have a single LED to each pin (2-13, 0 and 1 are left out so I don't have to unplug when uploading a new sketch). They are 3 volt 10ma LEDs, and I have a 100 ohm resistor on each. From what I can see, there shouldn't be too many issues with power from this. The spec sheets say up to 40ma per pin for the Duemilanove. To be safe, I tried both with USB, and with external power (10.8v laptop battery thats on it's last leg.) and it does it on both, as well, even if I turn off most of the LEDs (only 2-3 active) it still freezes for at least 10 seconds.

My laptop is able to power a Mimo Monitor with 1 mini-b plug (sometimes requires two plugs if your pc can't handle the power) so I know it's not an amperage issue on the computers part.

Any help on this?

They are 3 volt 10ma LEDs, and I have a 100 ohm resistor on each

(5V - 3V) / 100 ohms = 20mA

20ma * 12 LEDs = 240ma

Absolute Maximum Ratings*
DC Current VCC and GND Pins................................ 200.0 mA

*NOTICE: Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.

It is very likely that you damaged the processor.

even if I turn off most of the LEDs (only 2-3 active) it still freezes for at least 10 seconds

That may be a bug in your Sketch. If you'd like help, post the code.

but I bet the leds were nice and bright!

Seriously, you may well have cooked the processor in the arduino but they're not expensive. You should probably plan to replace it even if it seems to mostly work.

In the mean time, post your sketch and try runing it with a few leds and larger current-limiting resisters - say 200 ohms.

Well, with my code, it's pretty much 30 seconds on the dot that it messes up. Then 30 seconds off, then 30 on again.

I ran the default blink sketch that comes with the arduino API, and it lasted for well over a minute, as well as I made it just stay on, and same thing, worked for over a minute without issues... I guess it is my code.

Either way, here is my code. I have a bit commented due to my testing with less pins.

/*
        Programmer: Randy Phillips
        Date: January 21st, 2010
        Description:
            Functions to cause blinks, sequences, and pulses
*/

int GlobalTime = 0;
int blinkLED = 2;
int sequenceLEDs[] = {8,9,10,11,12,13};

void setup()
{
/* for(int i = 2; i <= 8; i++)
 {
    pinMode(i, OUTPUT);
 }
 */
// Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop()
{
 updateTime(); 
 ledBlink(13, 50, 50);
 /*ledPulse(3, 1000, 1000, 100, 0, 35, 255);
 ledBlink(4, 100, 50);
 ledPulse(5, 1000, 1000, 100, 0, 35, 255);
 ledPulse(6, 1000, 1000, 100, 0, 35, 255);
 ledBlink(7, 1000, 1000);*/
// ledSequence(sequenceLEDs, 1000, 1000, 6);
}


/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||    Personal Functions Below    |||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/


void updateTime()
{
  GlobalTime = millis();
}

void ledOn(int pinNumber)
{
  digitalWrite(pinNumber, HIGH);
}

void ledOff(int pinNumber)
{
  digitalWrite(pinNumber, LOW);
}

void ledBlink(int pinNumber, int offTime, int onTime)
{
  /*
    Blink:
      pinNumber - Pin to blink on and off
      offTime - Length of time in milliseconds to be off
      onTime - Length of time in milliseconds to be on
  */
  
  int elapsed = GlobalTime % (offTime + onTime);
  if(elapsed <= offTime)
  {
    digitalWrite(pinNumber, LOW);
  }else{
    digitalWrite(pinNumber, HIGH);
  }
}

void ledSequence(int pins[], int offTime, int sweepTime, int numberOfLEDs)
{
  /*
    Sequence:
      pins - The pins you want to run in sequence, in the order want them to run
      offTime - Length of time in milliseconds to be off
      sweepTime - Length of time to go from first pin in sequence to last pin, not length of time for each individual pin
      numberOfLEDs - The number of LEDs to be lit in the sequence
  */
  
  int elapsed = GlobalTime % (offTime + sweepTime);
  int currentPin = 0;
  if(elapsed <= offTime)
  {
    for(int i = 0; i < numberOfLEDs; i++)
    {
      digitalWrite(pins[i], LOW);
    }
  }else{
    int newElapsed = elapsed - offTime;
    currentPin = map(newElapsed, 0, sweepTime, 0, numberOfLEDs);
    
    for(int i = 0; i < numberOfLEDs; i++)
    {
      if(i == currentPin)
      {
        digitalWrite(pins[i], HIGH);
      }else{
        digitalWrite(pins[i], LOW);
      }
    }
  }
}

void ledPulse(int pinNumber, int offTime, int fadeTime, int pulseTime, int minValue, int maxValue, int pulseValue)
{
  /*
    Sequence:
      pins - The pins you want to run in sequence, in the order want them to run
      offTime - Length of time in milliseconds to be off
      sweepTime - Length of time to go from first pin in sequence to last pin, not length of time for each individual pin
      numberOfLEDs - The number of LEDs to be lit in the sequence
  */
  
  int elapsed = GlobalTime % (offTime + fadeTime + pulseTime);
  if(elapsed <= offTime)
  {
      analogWrite(pinNumber, 0);
  }else{
    int newElapsed = elapsed - offTime;
    if(newElapsed <= fadeTime)
    {
      int fadeValue = map(newElapsed, 0, fadeTime, minValue, maxValue);
      analogWrite(pinNumber, fadeValue);
    }else{
      analogWrite(pinNumber, pulseValue);
    }
  }
}

And, if I did my math right, wouldn't a 200 ohm resistor make it 15mA per led? (180 total)

Change GlobalTime...

unsigned long GlobalTime = 0;

And, if I did my math right, wouldn't a 200 ohm resistor make it 15mA per led? (180 total)

(5V - 3V) / 200 ohms = 10mA

That was the issue, though, in looking at my code, I don't need that variable as I can simply just use millis() any play I had GlobalTime...

O-o I guess that's a simpler answer, as then it doesn't need to run an extra function.

Thanks for the help, I really appreciate it.

:o I really need a crash course in electronics... Ohms law just doesn't click with me for some reason...