After doing a bit of reading, I think I have damaged one of the pins on my Diecimila.
I accidentally set pin 7 as an output instead of input and then wired it up as a button. Now when I set pin 7 as an input, it always reads a high value, even when there is nothing wired to it.
Is there anyway to fix a damaged pin short of replacing the ATmega168?
I'm afraid not. When you set the pin as an output by mistake and then when you wired a push button to it and pressed the switch you 'short circuited' the output pin, causing it to draw much higher then it's rated 40ma max output current. Chip is still useful, just one less i/o pin
When wiring switches to digital i/o pins, if you wire a series resistor of say 2K ohms between the switch and the pin, the pin will be protected in case it evers gets to be assigned as an output pin by mistake.
Hang on a sec, though. I don't think digtally reading HIGH from an unconnected pin proves that it's broken. A floating (disconnected) pin could very feasibly read HIGH without being broken. Tie the pin to ground and see if you still get the "HIGH" reading. That'll be the proof you need.
Mikal
Also, did you digitalWrite() the pin at all after setting it as mode input? There's an internal pull-up resistor you could've enabled.
I'd follow Mikalhart's suggestion first, before giving up on the pin =)
!c
here
u can read how to disable the pull-up resistor...
Also, did you digitalWrite() the pin at all after setting it as mode input? There's an internal pull-up resistor you could've enabled.
I think you've got it the wrong way around - the OP said they set the pin to OUTPU mode, then connected it as an INPUT. THis is the opposite of enabling the internal resistor, and definately could cause the pin to be damaged.
Now when I set pin 7 as an input, it always reads a high value, even when there is nothing wired to it.
I think you've got it the wrong way around - the OP said they set the pin to OUTPU mode, then connected it as an INPUT. THis is the opposite of enabling the internal resistor, and definately could cause the pin to be damaged.
Yes, it is possible the pin is damaged, we're just suggesting a few tests and things to look for before throwing the chip away.
!c