Go Down

Topic: Mega 2560 - Led 13 often on without code (Read 2085 times) previous topic - next topic

thierry_b

Hi,

Could you tell me why this simple code put onboard Led 13 always on ?

/*
*
* Controle d'un relai apr├Ęs un certain temps
*
*/

int pinRelai = 31; // commande du relai (via transistor P2N2222AG)


void setup() {
  pinMode( pinRelai, OUTPUT );
}

void loop() {
  delay(5000);
  digitalWrite( pinRelai, HIGH );
  delay(5000);
  digitalWrite( pinRelai, LOW );
 
}

billroy

What size resistor do you have connecting the digital output pin to the base of the transistor?

-br


billroy

I'm stumped.  An interesting mystery.  The relay is happy, right?

-br

thierry_b

Yes relay does function.

With some code, Led is on, with other it's off

Strange

Thierry

PaulS

Quote
With some code, Led is on, with other it's off

Strange

Not really. Whether the pin is INPUT or OUTPUT matters. Whether the pin is HIGH or LOW matters. Without seeing the two different codes, all we can do is assume that it is perfectly normal.

JimboZA

I have a Uno and find that with sketches which don't even refer to that pin at all, the built-in led on 13 is on more often than not.

I stick these lines in at the top of each sketch, because having that led on when I don't want it on, annoys the cr@p out of me!

Code: [Select]
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);

My hovercraft is full of eels.

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

billroy

Sounds like a bootloader bug.  Worth reporting if it's an official Arduino board.

-br

thierry_b

--> PaulS

You have an example of code in my post.  I juste do copy-paste as a new program, run it and Led will light

thierry_b

--> JimboZA

Nice to meet another one with same problem  :-)

Thierry

tres

hi all,

i just received my arduino mega 2560 r3 and led on pin 13 is always on, even with "bare minimum" sketch.
when i use the blink example it blinks correctly.

have you found any solution to this?
is that the only problem you have or might this be just the tip of the iceberg and the whole board is flawed?

cheers,
stefan

PaulS

I drug out a selection of Arduinos - a Duemilanove, a Micro, a Mega, a Leonardo, a Due, and an Esplora. I loaded the same sketch onto each one. On the Due, the LED on pin 13 stayed on. On all the others, the LED on pin 13 was off while the sketch was running. Changing the pin from 31 to 13, for each board, caused the onboard LED to flash, as expected.

I guess, then, that JimboZA's suggestion is what you need to do, if having the onboard LED on bothers you.

tres

hi Paul,

whoaa, thanks for your investigation!
so pin13 is off on your MEGA but on on the DUE... seems random to me ;)

a resistor from pin 13 to ground "solves" the problem, i just hope that there aren't any underlying defects that cause this behavior.


thanks again,
stefan

PaulS

Quote
a resistor from pin 13 to ground "solves" the problem

That is what JimboZA's code does, in effect, but all in software.

Delta_G

Could a floating pin somehow drive the LED?

Go Up