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?
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.
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.)
I didn't saw! INCREDIBLE!!!!! And you realize that I've searched a lot before open a new topic! THANK YOU SIR!
@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.