Input with LED switches

Status
Not open for further replies.

jonfitt

Member
I have some nice toggle switches with LEDs in the shaft. They didn't come with a diagram, but best I can tell it's essentially this:
https://imgur.com/a/hngY4

What is the best practice for using this as a digital input? If I use the pull-up method then closing the switch and grounding the pin won't give me any voltage across the LED.

I know I'm going to slap my forehead when someone replies, but I can't quite see the elegant way to do it.
 
Is the way to connect the top pin to a voltage source, the LED pin to a ground through a resistor (1k?), and the third pin as an input with the code set to PULL_DOWN?

What pin is recommended for +ve voltage? VIN or a 3.3v one?
 
Last edited:
Ok, so that seems to work. Both VIN and the 3.3v as high seem ok, the 3.2 Teensy copes woth both.
I didn't put a resistor when using the 3.3v, the LED seems to have enough resistance.

Unless anyone has any objections I think my above assumption works.
 
So I guess you want the LED to light when the button is pressed?

I'd put a resistor in to protect that LED, That's waiting to pop without one. And go for the 3v3 so you know for sure what voltage you're using.

I'm guessing you're powering from USB, so your Vin is around 5v. Of course, Vin is pinned out, so could be higher voltage if powered from the Vin pin from an external supply. In any case, you don't want to provide excessive voltage onto the micro pin when your switch is pressed. So use 3v3 for your circuits. The regulator will keep you safe from damage.
 
I have no data sheet for these switches. I have a couple of different kinds with different sized LEDs, but I don't know their ideal operating current/voltage, or their maximum.
Is there a rule of thumb for what current I should be aiming for?

Also a factor that would play into that. What current can I expect to get safely from the 3.3v pins on the Teensy?

Obviously the max total for USB 2.0 is 500mA, and 900mA for USB 3.0, but there are obviously lots of other factors not least the draw of the Teensy itself.

Oh BTW, I'm a Colchester boy myself, now living in Colorado, USA ;)
 
Last edited:
If you have no data sheet for the part, I'd say rule of thumb, go for 10mA across an LED. Maybe slightly more, 15mA maybe, but not much more than that for an unknown device.

On a micro pin, I think the max is 25mA per pin. Not sure what the max for the whole device all at once is. How many of these switches are you planning to use in your design?

I'm a Dagenham boy originally, now living in Colchester. Nice to get out of London, but not too far away.
 
So each switch will look like this:
https://impur.com/a/b9xya

I'll work on R to get the current through the LED to be 10-15mA.

But each one of these switches would draw from the 3v3 pin which gets power from the regulator.

Total I'm planning on 10-11 switches and buttons that are lit. So that's 150-165mA if I'm interpreting that right.
 
Status
Not open for further replies.
Back
Top