MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

icon
Avatar
capitainekurck
Posts: 24
Hello

I need to connect several leds to my mega and other componants. i plan to use a transistor to drive each leds. a 2N222 seem to be good. https://cdn.sparkfun.com/assets/learn_tutorials/1/9/3/npn-switch-led.png. But how can i calculate that the current that the transistor drain to not be over the 200 mA that the mega can give on is total E/S pins

regards
Lionel
2019-05-19 16:29
Avatar
StephanHo
From: EDDG, Germany
Posts: 1446
Supporter
Hi Lionel,

what kind of LED do you use if they need a current of 200mA??

With MobiFlight and a Arduino MEGA you need no transistor to drive a LED. If you take high brightness LED you can drive them with less than 10mA. So you can use 2 high brightness LEDD per Output.
The resistance depends on the voltage dropping across the LED. To calculate the resistance, you only need ohm's law.

R(resistance)= (U(voltage overall) - U(voltage LED)) / I(current)

If you have a LED which needs a Voltage of 3V and your overall Voltage is 5V then will drop a voltage of 2V will drop over the resistance.
If you want to drive the LED with 10mA the your calculation is as follows:

R=2V / 0,01A or R= 2000mV / 10mA

R=200 Ohm

200 ohms is not a resistance of the normal E-rows so take 220 (red red brown). This formula can be used for every calculation regarding resistance for LED.
Grüße,
Stephan
2019-05-19 16:54
Avatar
capitainekurck
Posts: 24
Thanks Stephan for you reply. i need quite 17 leds. with 10 mA, if i use high brightness LED, i will need quite 170 mA so it will be close to 200 mA.and for the the future to drive all annuciators i look tu use transistors to not load hightly the E/S of mega. in a other way as i not electronician :blush: i m interest to know the difference of drain power wit a transistor and without a transistor

regards
2019-05-19 17:08
Avatar
StephanHo
From: EDDG, Germany
Posts: 1446
Supporter
Lionel,

I can not imagine that you want to operate all 17 LEDs via an output on the MEGA.
If you want to operate every LED with 10 mA, then this load for the MEGA is quite acceptable.

Basically, you can load up to 40mA at the MEGA each output, but in total never more than 800mA.
With MobiFlight you can operate up to 40 LEDs individually. It can be assumed that never all LEDs are switched on at the same time.
So I see no need to operate the LED via upstream transistors. I dare to say that nobody here does that.

A tip from me: since the respective LED colors shine differently bright (also the high-brightness) you should try out the brightness individually.
Try the resistance values of 180, 220, 330, 470 and 1000 ohms. If you have a multimeter, you can measure the current or calculate it by changing the formula.
Grüße,
Stephan
2019-05-19 23:18
Avatar
capitainekurck
Posts: 24
hi Stephan,

I never said that i want to connect all 17 led on the same output of my arduino. i just want to know how to calculate the current that a transistor need vs a led connected to an output of my arduino. I m interested with it because it can serve me to connect thing tat need more power than the output can give ex a relay or a bulb or coil ....
2019-05-20 02:11
Avatar
StephanHo
From: EDDG, Germany
Posts: 1446
Supporter
Hello Lionel,

of course you thought wise and gentle on materials.

The current required by a transistor control is much lower (factor 200 - 1000) than the driving of an LED.
If you would drive the LED with 10 mA, a transistor needs about 100μA depending on the wiring.

Since you want to operate the transistor as a switch, you can use the circuit you linked. A calculation of the current flow is not required in this type of wiring, since it is negligibly small.

In the name you certainly meant the 2N2222, a bipolar NPN transistor. But here you have to pay attention to the limits. This transistor may be max. let a current of 800mA flow and the power loss must not exceed 500mW. So, if you know the current flowing through the transistor, then you just measure the voltage that drops on the C-E path (collector-emitter) and multiply it by the current to get the power dissipation. For inductive load (coil, relay) please think of the freewheeling diode.
If more power is required, you can also use the transistor to switch a relay. Relays can switch currents far beyond 10A.
Grüße,
Stephan
2019-05-20 13:44
Avatar
capitainekurck
Posts: 24
Hi

Thanks for your reply and explanation, yes i mean 2N2222. Ok for the freewheeling diode, on sparkfun site where i took the pic there is on other picture for a motor with the the freewheeling diode.
If i need more power i will use a mosfet.
and the last 2 questions :blush:
Is it possible to drive the transistor with a 5V from the arduino and use a motor or a coil with less or more voltage (ex 3V or 12V) ?
And some LED that i will dim with a pwm board ?
2019-05-21 19:43
Avatar
StephanHo
From: EDDG, Germany
Posts: 1446
Supporter
Hi Lionel,

you mean that you drive the base of the transistor with an output of an Arduino MEGA (0..5V) like pictured on the sparkfun site and use another voltage on the line Collector / Emitter?
Did you take the 3V or 12V from an external power supply then make sure the GND is connected by the MEGA and the external power supply and have a look to the current to this items so that the power loss does not exceed.

When operating LED with PWM, you control the base normally (as if the Transitor acts as a switch), put the PWM voltage to the collector and the LED to the emitter side. Do not forget the series resistor for the LED!
Grüße,
Stephan
2019-05-23 01:13
Avatar
capitainekurck
Posts: 24
Thanks Stephan for you explanation.

Yes i will plan to use an external 5 V power with a shield like that https://www.ebay.fr/itm/Mega-Sensor-Shield-V2-0-V2-For-Arduino-Mega2560-R3-ATmega16U2-ATMEL-AVR/173439319282?hash=item2861c9fcf2:g:zZMAAOSw0HhbXnKd
2019-05-28 00:55
icon