LED on SS pin

hello,

I have question about connecting resistor to transistor.

In my project I want to have LED indicating device that is currently active.
I do it on SPI bus connecting led to SS pins, as you know, in such solution I have to invert login on SS pin. I also would like to have resistor for limiting power and brightness of led.

Which of solution shown below is correct and why?

why not just

DATA ----[ R ] ----- [ LED ] --- GND

?

Neither of the circuits are optimal because they both take more current when the LED is off. The transistor is being used as a switch in parallel with the load instead of in series with the load which is the preferred technique.

With an LED and series resistor the Arduino output can drive this directly if current is 30mA or less - and you can drive in either sense (active high, active low) as the Arduino sources and sinks current equally well.

If the data line is going somewhere else you need a resistor in the base to limit the base current. That sort of switching is known as shunt switching and as was said is not very common.

I cannot connect led to ping becouse SS (Slave Select) from SPI works in inverted logic.

It is HIGH when device is deselected and LOW when we select device, so in order to lit led when device is working (is selected) I have to Invert logic (Led lit when SS is LOW).

I do not know other solution, if there is any I would appreciate any tips.

It is HIGH when device is deselected and LOW when we select device, so in order to lit led when device is working (is selected) I have to Invert logic (Led lit when SS is LOW).

I do not know other solution, if there is any I would appreciate any tips.

Yes, simply wire the external led such that it's anode pin is wired to ground and it's cathode pin is wired through a series current limiting resistor to the SS pin. When SS pin is low, led will light up.

Lefty

Yes, simply wire the external led such that it's anode pin is wired to ground and it's cathode pin is wired through a series current limiting resistor to the SS pin. When SS pin is low, led will light up.

Wouldn't the SS pin have to be less than 0 v (assuming ground is 0v) for the LED to be forward biased?

Isn't this an application for a PNP transistor? +5v --> resistor --> LED anode. LED cathode --> PNP emitter. PNP collector --> GND. SS --> resistor --> PNP base.

Don

I'm sorry I kind of screwed that up. For a led with resistor to light up when a output pin (your SS pin) is low only requires you wire the resistor to the SS pin, other end of resistor to the cathode of the led, anode of the led wires to +5vdc pin. The led will be forward biased (and light up) when the SS pin is low.

Lefty

thanks!

I've tried your solution and it worked like a charm!
Now I have will have some space (left after deleting transistors) on PCB to correctly align parts.

I come out with something like this:

I put there potentiometer so I could adjust resistance in order to get correct voltage on SPI SS pin.

My device require 3v3 voltage on spi bus (for mosi, miso, clk and interrupt I user lever converter) so SS i must convert by myself.

And my second question is: Which is better for converting 5v to 3v3 .. a voltage divider built from two resistors (GND -- RES -- SPI SS -- RES -- DEVICE) OR one resistor with calculated value ( SPI SS -- RES -- DEVICE) ?

Which is better for converting 5v to 3v3

Do not use a single resistor, that is a very bad solution and will not work reliably. A potential divider is a bit of a fudge but might work, the best way is to use a level converter FET.

Hmm is this required for one way conversion (5V->3v3) ?

I just looked at sparkfun level converter and for such conversion they use two 10k resistors

[quoteis this required for one way conversion (5V->3v3)][/quote]
For maximum signal fidelity, speed and noise immunity then yes. However as I said a potential divider is a fudge that will work in most (but not all) circumstances.

Thanks for answer.

For this project I will go with wimple voltage divider (since I do not need to wory about noise).
In next one definitely will go with FET