Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Drop voltage on some pins  (Read 842 times)
0 Members and 1 Guest are viewing this topic.
España
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19768
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have resistors in series with the LEDs?
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17320
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19768
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

May we see it? And your wiring?
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

España
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19768
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

España
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

 smiley-lol

Ok, here is the sketch:
Code:
#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! smiley

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)
« Last Edit: April 10, 2012, 02:57:04 am by Nick Gammon » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 216
Posts: 13140
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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);
}
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19768
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Where do you set the pin to output?
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19768
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty knew. smiley
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 216
Posts: 13140
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


He always does.   smiley-cool
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 139
Posts: 6835
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
Logged

España
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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? smiley


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

Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: