LED pin #13 on with out code.

I have a sketch that is quite long and involved on a stand alone Uno with no other devices attached. . I made a bunch of small changes and notice the on-board LED is on and stays on from the moment the program starts. No where in my code is pin 13 set to HIGH. What could be causing the on-board LED on the Uno? This has not happened before with this program or project.

Thank you.

Does your program use an SPI interface for anything ?

No. I use the Arduino IDE only and use the cable to upload the sketch.

I think that you may have misinterpreted my question. Are there any external devices connected to the Arduino and if so, how ?

Without seeing the code and the schematic/connections you’ve got to it all we can do is guess.

If you aren’t explicitly doing anything with pin 13 then are you doing anything using an array of bytes to, say, set pin modes or states?

For example:

const byte pinDefinitions[] = { 2, 3, 4, 5, 6, 7, 8 };
.
.
.
void setup( void )
{
    for( byte i=0; i<7; i++ )
    {
        pinMode( pinDefinitions[i], OUTPUT );
        digitalWrite( pinDefinitions[i], HIGH );
    }//for
    .
    .
    .
}//setup

If so, are you sure you’re not referencing outside the bounds of the pin array?

UKHeliBob: Nothing at all attached to the Uno.

Blackfin: No, no changes of state any place. Its a program that does some some math and comparing with arrays, but does not change any pin states: just gives the answer to the monitor screen

Does the Blink sketch work?

Reduce your sketch to bare minimum where it still exhibits the problem then show it to us.

I have a UNO like that, too. I don't think it's a clone, but --

pinMode(13,OUTPUT);
digitalWrite(13,LOW);

'problem' solved

runaway_pancake: Thank you! That did the trick!

Problem solved!

Thank you everyone!

Still doesn’t address the ‘why’
Is it an oddball bootloader, or some other hardware anomaly... or is there a magic gremlin lurking that will cause issues for the OP later ?

lastchancename:
Still doesn’t address the ‘why’
Is it an oddball bootloader, or some other hardware anomaly… or is there a magic gremlin lurking that will cause issues for the OP later ?

Possibly floating input on the LM358 (if it’s an original).

sterretje:
Possibly floating input on the LM358 (if it's an original).

The newer design seems to turn on the LED when the pin is not driven low.
i.e. if the pin is in input the LED will be on.

The original/old design didn't have this issue since the Arduino pin directly powered the LED.

--- bill

"Pin 13 is an input for an op-amp. If there is a voltage on pin 13 the op-amp will match that voltage on its output which drives the LED. Because INPUT pins have high impedance, without a pull-down resistor their voltage will float, or perhaps there is a miniscule leakage from the micrcontroller and without a pull-down resistor there will be voltage on the pin. Op-amp inputs have a theoretical infinite impedance."
*"*It appears that the UNO r3 works differently from earlier versions. (This is a design improvement.) With the old version you couldn't use pin 13 as INPUT-PULLUP because the voltage would only be 1.7V because the LED was draining the current coming through the pull-up resistor. With the UNO R3 the op-amp won't drain the pull-up current allowing us to set pin 13 as INPUT_PULL-UP. The Pro-mini still has the old design however, and if you want to use pin 13 as INPUT-PULLUP you have to flick the resistor off the board."