Go Down

Topic: Strange digital pin behaviour (Read 882 times) previous topic - next topic

agent_orange

Nov 21, 2007, 12:10 am Last Edit: Nov 21, 2007, 12:12 am by agent_orange Reason: 1
I am getting some strange behaviour and trying to figure out what is going wrong. If I connect a LED with 220 ohm resistor to any other pin than pin 13 I am getting very low output, like there is very little current for that pin. I have the pins configured as outputs in software. On pin 13 the LED is bright, on any other pin it is very dim.

I've also tried this with 2 different atmega 168 chips, so the chip itself doesn't appear to be the problem.

Daniel

assuming you have written to the pins with the command
digitalWrite(PIN, HIGH), then it should be OK. How do you have it wired?
Is there anything else connected? What's the code you're using?

D

agent_orange

I changed the pins to output pins and use digitalWrite(pinNum,HIGH). It seems like the pins can't supply much current. If I have an LED connected on pin 13 it appears dim on one atmega168 and bright on another. Connecting a digital pin through a LED and then a 220 ohm resistor, some appear bright and others appear dim. It's got me stumped whats causing the problem. I'm using a USB arduino NG modified to work as a decimelia. I have the original atmega168 that came with that and also three new ones I burned with decimelia bootloader. All the code works fine, they just don't supply much current.

westfw

My 168 provides plenty of current.  In this video, the AVR is both sinking and sourcing current on digital IO pins (and there isn't any current limiting resistor) BareBones KIT LEDs

Are you sure of your resistor value (should be Red, Red, Brown)?  Sometimes a red or orange band will look a lot like brown, and you can't trust whoever threw them in the bin/bag/whatever "for sure."

agent_orange

#4
Nov 22, 2007, 06:41 am Last Edit: Nov 22, 2007, 06:42 am by agent_orange Reason: 1
Its nowhere near that bright. I've checked the resistors using a multimeter. I've also checked the voltage using an oscilloscope. Some of the pins appear  bright and some don't. For example, one mega168 will have a bright output on pin 13, the next one won't, it will be quite dim. Even with no current limiting resistor the LED's are dim. I ordered the extra 168's direct from atmel as samples so I can't see that 3 samples would all be bad. I don't know if its something to do with the board itself. I'm thinking of buying a new decimelia and seeing how that is.

kuuk

did you check the voltage on your pins and current through the resistor using your multimeter?
you wrote you declared your pins as outputs using pinMode(pinNumber, OUTPUT), right?
if you got your atmegas blank from atmel, you might try to burn the bootloader again (or try another) and have look on the fuse settings if you don't use arduino to burn the bootloader. some pins have internal pull-up/down resistors. i'm no expert on that. but since there are different bootladers available, i can imagine these a reason for the lost power.

another reason might be some short circuit on your modified NG board. but since your writing it affects all boards...

do the pins behave the same trying one chip across different boards? this would hint at an defective atmega or wrong bootloader.

i hope you can track the problem down before ordering a new board. these things tend to happen again and again.

kuk

killerdark

I think I know what was the cause of this.

If you forget to set the LED pin to output, you get that effect. Make sure that this is included in the setup() part of the script:

Code: [Select]
 pinMode(ledPin, OUTPUT);

Replace ledPin with whatever the name of your pin is.

Grumpy_Mike

Looks very likely killerdark but then on the original post he did say:-

Quote
I have the pins configured as outputs in software.


But I agree this would fit the symptoms.

mdowning

Can you measure the voltage difference between pin 13 and any of the other digital pins?  Ditto for the +5V line.

One other thing you can try is to use the Blink code on pins besides 13 and see if the dim LEDs turn on an off like they're supposed to.  If they don't you have some bigger problem.

It's strange you mention that with one ATmega chip the pin 13 LED is bright and on others it's dim...
Cheers!

Go Up