Using input to drive LED

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

Hi

Im making a circuit with volt free contacts into a Tiny24.

Im switching the gnd to my input via contact between the 2 terminal. I have attached a wiring diagram.

Im would also like to add a LED that lights when the terminals are joined. Ideally i could allocate these to an output each from my Tiny but all of my IP are used up.

I was considering using the same GND to activate an NPN transistor to control the LED. I dont presume there should be any problems with this, should there...?

Attachment(s): 

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

The convention would be to use an internal pull-up on an input pin, and switch to GND. You can add a small resistor if you like, but it is not necessary.

You can drive your LED directly from an output pin. ( with a current-limiting resistor)

There are several tricks if you are short of input pins. Exactly which AVR, and what i/p and o/p do you have?

David.

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

Im using an AT Tiny 24.

I dont have any extra output pins to allocated to the 4 LEDs thats why i was wanting to use the same switched ground to pull low the input and also drive a transistor to control an LED (showing that the input is activated)

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

You have 14 pins on your Tiny24. Avoiding Vcc, GND and !RESET, this leaves 11 available for i/o.

Even with an 8 pin Tiny, you can have 4 o/p, 1 i/p, Vcc, GND, !RST

So I do not see why you have a problem.

David.

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

But Im saying that Ive allocated the other IO pins already and have only got 4 to play with.

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

Your in luck, the Tiny24 has an ADC - put as many buttons as you like on that with a switched resistor ladder. So that's all your buttons now on one pin - does that clear enough pins?

The possible downside is multiple button detection. Say you pick the resistors so that with 5 buttons, button 1 makes 1V, button 2 makes 2V and so on. When you read 4V it may be tricky to know if it's just button 4 or button 1 AND button 3.

EDIT: A quick Google returns this:

http://www.scienceprog.com/inter...

Last Edited: Tue. Sep 29, 2009 - 02:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a logic gate to drive your LED. look at the Tiny logic families which have a single gate in a 4 or 5 pin SMD package. use the gate to pull a ground on the LED with the other side tied to VCC with a current limiting resistor. When the gate input is shorted to ground it will light the LED.

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

What if the volt free contact is from a mains powers device such as a contactor.
Would an RC filter such as the one in my original diagram be required to remove the 50hZ hum from the mains?

justin