Offline
Newbie
Karma: 0
Posts: 13
|
 |
« on: December 08, 2012, 11:39:44 am » |
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 ); }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #1 on: December 08, 2012, 11:49:25 am » |
What size resistor do you have connecting the digital output pin to the base of the transistor?
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #2 on: December 08, 2012, 12:16:27 pm » |
10k ohm
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #3 on: December 08, 2012, 12:26:47 pm » |
I'm stumped. An interesting mystery. The relay is happy, right?
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #4 on: December 08, 2012, 12:28:39 pm » |
Yes relay does function.
With some code, Led is on, with other it's off
Strange
Thierry
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #5 on: December 08, 2012, 12:43:08 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Johannesburg UTC+2
Offline
Edison Member
Karma: 34
Posts: 1705
|
 |
« Reply #6 on: December 08, 2012, 12:52:29 pm » |
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! pinMode(13, OUTPUT); digitalWrite(13, LOW);
|
|
|
|
|
Logged
|
IT Crowd: Roy... "Have you tried turning it off and on again?" Moss.. "Have you tried forcing an unexpected reboot?"
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #7 on: December 08, 2012, 12:55:33 pm » |
Sounds like a bootloader bug. Worth reporting if it's an official Arduino board.
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #8 on: December 08, 2012, 01:06:02 pm » |
--> 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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #9 on: December 08, 2012, 01:07:24 pm » |
--> JimboZA
Nice to meet another one with same problem :-)
Thierry
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Newbie
Karma: 1
Posts: 38
|
 |
« Reply #10 on: January 28, 2013, 01:56:18 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #11 on: January 28, 2013, 06:37:02 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Newbie
Karma: 1
Posts: 38
|
 |
« Reply #12 on: January 28, 2013, 06:48:41 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #13 on: January 28, 2013, 06:55:16 pm » |
a resistor from pin 13 to ground "solves" the problem That is what JimboZA's code does, in effect, but all in software.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 5
Posts: 396
|
 |
« Reply #14 on: January 28, 2013, 07:44:32 pm » |
Could a floating pin somehow drive the LED?
|
|
|
|
|
Logged
|
|
|
|
|
|