Go Down

Topic: Drop voltage on some pins (Read 916 times) previous topic - next topic

suirammarius

Hello!

I have an Atmega328P standalone. I've uploaded a sketch, and it functions perfect. The problem is when I connect a LED to some pins (eg. PD6, PD7..) the LED narrowly lights. I've measured the drop voltage on the LED+resist. an it has almost 2 V.
Why just some pins does this?
Could anyone explain how could I avoid this? The transistor is the only solution?

Thank you!

Nick Gammon

Do you have resistors in series with the LEDs?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

retrolefty

Did you remember to do a pinMode command on the pins you wired the led/resistors to?

Lefty

Nick Gammon


I've uploaded a sketch, and it functions perfect.


May we see it? And your wiring?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

suirammarius

Yes, I have a resistor.
There is nothing wrong with the wiring or with the sketch. Without a load, I have 5V between the pin and GND. When I conect the LED (with the resistor) the drop voltage on the load is, as I said, about 2V.

Nick Gammon

Quote
There is nothing wrong with the wiring or with the sketch.


Ah, if I had a dollar for every time I heard that ...

So no sketch? No wiring?

Quote
The transistor is the only solution?


The solution is to answer our questions.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

suirammarius

#6
Apr 10, 2012, 09:34 am Last Edit: Apr 10, 2012, 09:57 am by Nick Gammon Reason: 1

Ah, if I had a dollar for every time I heard that ...
(...)


XD

Ok, here is the sketch:
Code: [Select]
#include <Wire.h>
byte c;
void setup()
{
 Wire.begin(4);                // join i2c bus with address #4
 Wire.onReceive(receiveEvent); // register event
 digitalWrite (6, HIGH);
 delay(3000);
 digitalWrite (6, LOW);
}

void loop()
{
 if (c==1)
 {
   digitalWrite (6, HIGH);
 }
 if (c==0)
 {
   digitalWrite (6, LOW);
 }
 delay(100);
}

void receiveEvent(int howMany)
{
 
 c = Wire.read();
   
 }

And this is the wiring; the yellow wire is the pin 6 from the sketch.


Thank you! :)

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)

Coding Badly

Quote
[font=Courier New]void setup()
{
  Wire.begin(4);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  pinMode( 6, OUTPUT );
  digitalWrite (6, HIGH);
  delay(3000);
  digitalWrite (6, LOW);
}[/font]

Nick Gammon


There is nothing wrong with the wiring or with the sketch.


Where do you set the pin to output?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


Did you remember to do a pinMode command on the pins you wired the led/resistors to?


Lefty knew. :)
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Coding Badly


westfw

So...  If you DON'T set the pin as an OUTPUT, writing a HIGH with digitalWrite() enables  the internal "weak pullup", which is a resistor of value about 20k to +5V.  This allows enough current to flow out the pin to tell a voltmeter that there is 5V there, and enough for a modern LED to light very dimly, but not enough to get the current you are expecting.  Effectively, you get the equivalent of a 20k+R current-limiting resistor to the voltage source, instead of just R.

Nice job on the picture and code posting, BTW.  A lot of the time when people are "sure" that their code/circuit is correct, that info NEVER shows up (which is why the responders are a little ... assertive about asking.)  Here, we got a good picture and the code quite quickly (and it did indeed make the problem obvious.)

suirammarius

:smiley-red:

I didn't saw! INCREDIBLE!!!!! And you realize that I've searched a lot before open a new topic!
THANK YOU SIR!

:smiley-red:

@Westfw:
Yes, I realized what happed when I saw that I forgot to declare the type of pin.
About the photo, the code... I've posted here because I didn't found any solution myself. So it's my interest to show as more explicit as I can the problem that I have. Isn't it? :)


PS This topic can be deleted because it didn't serve for something and I have the "problem" (that was a shame) solved.


Go Up