Will this LED and Button arrangement damage the I/O pin?

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi folks,

I already sent my design off to the fab house and realized that I made an error in the design. I have one pin driving an LED and reading a button. But I didn't add a resistor on the button side. Here's what the schematic looks like:

PB#--------Switch-------GND
     |
     ----LED--Resistor--GND

I should have put a resistor on the button leg of that circuit. Am I going to burn out the I/O pin if I'm polling the switch every 10ms?

This LED is not integral to the design. In fact, I added it at the last minute to help when writing code for the device. But just want to get another opinion on whether this is salvageable in code or not. Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The led + resistor combination may just be enough to keep the pin low as if the switch was pressed.

And yes your chip will be upset by the switch being pressed while the pin is in output mode driving the led.

That's why very sharp knives were invented in order to cut tracks on PCB prototypes and add resistors.....

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the LED is not part of the production build then you don't have a problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the way you have it is not good, but with a little re-arrangement it can be made safe.

PB#--------Switch-------GND
     |
     ----LED--Resistor--VCC

Pressing the switch, or driving the pin low will turn on the LED. When off, the LED & resistor will act like a pull-up holding the line high.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depending on the forward voltage of the led you could set the pin to input and use an internal pullup. That way switching it to ground would be fine and that would also turn off the led. Try a white led with a >3V forward voltage. It will be dim but it will work just fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

metron9 wrote:
Depending on the forward voltage of the led ...
... and the supply voltage...

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How many boards do you have?

As is, you will damage the I/O pin when it is High, driving the LED, and you short it to ground with the switch. At least you recognized the problem before you fried a board!

I agree with the others. If you don't need the LED any more and program the pin for input only, with the internal pull up resistor on, then you are in good shape.

If you still want the LED and the switch, then I like JS's approach, cut the trace to the switch, or from the switch to ground, and insert a small series resistor in the line.

If you have multiple boards then you would still only have to do this on one board, for your code development, and then just not install the LED on the other boards.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
     o vcc
     | 
     [] R
     | 
     V  LED
-+   |
 |---+ avr io
-+   |
       |  switch
     |
     V  gnd

You can use the button as a pushon-pushoff software toggle for the lamp. To read the button when the led is on you just need to turn the output off real quick to read the input, then turn it back to output.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Barney,

Glitch's/Bob's suggestion will require a hardware modification, just as will JS's.

You will have to look at your PCB layout to see which is actually easier to impliment. Depending on the layout one may be much easier than the other.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He can easily do it with a fly-wire, if he must absolutely have both. Remove the Resistor, and re-install it such that it is only connected to the LED side, and connect the other side [by wire if necessary] to the nearest VCC point. [No cutting required!]

If he does not need both, the easy answer is to leave one of them off the board.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks all. I will probably use Bob's suggested circuit and connect a wire jumper from LED to a resistor and VCC. I suppose this acts as the pull-up for the switch.

Once the firmware testing is done I'll depopulate the LED and they won't go on any other boards.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

barney_1 wrote:
I suppose this acts as the pull-up for the switch.

See my first post

Writing code is like having sex.... make one little mistake, and you're supporting it for life.