Hi there, complete beginner here, and my first time using transistors so apologies if this seems stupidly simple.
Basically i'm trying to use 2 arduino output pins through BC639 NPNs as switches to charge/discharge a capacitor from a 7.2v battery through an LED.
The issue i'm having is that on the breadboard the LED lights up after a few seconds of the top transistor being powered even when the second transistor is 'off' (base-emitter current from Arduino is zero) which I don't want. I believe it has something to do with capacitor voltage across the collector-emitter causing the second transistor to 'leak' but i'm not sure
I'm at a bit of a loss as to whats going on so if anyone could guide me in the right direction here that would be great.
The battery is 7.2V and the Arduino pin is 0V or 5V.
Suppose you want to charge the capacitor, that won't work, since you use an NPN transistor. The capacitor will charge up to 3.8V.
May I suggest something ?
Draw a big horizontal line. That is your ground.
Connect the Arduino GND, the '-' of the battery and the '-' of the capacitor all to that ground.
Discharging is easy, a transistor with emittor to ground and collector to led+resistor to capacitor.
Charging requires an extra PNP transistor. Do you have a BC640 ?
Using the diodes did almost make it work, and it's not a bad idea, but you missed a few things. I don't know an easy fix for this circuit.
Remember that the base of a transistor may not be connected to an Arduino output, you have to use a resistor to the base.
Ok, thanks for the reply, I have some 2N3702 PNP transistors so i'll try redesigning the circuit as you suggested
two quick follow up questions:
you say the capacitor will only charge to 3.8V, is this caused the transistor choice? the capacitor actually charges fully to ~7.2v in the circuit wizard simulation but I believe this uses an 'ideal' transistor model.
In general, is it ok to use a single resistor on the arduino GND path rather than for each output pin, as I did in the above circuit?
You'll probably just confuse yourself continuing with that circuit.
You have spurious diodes for no apparant reason.
You don't seem to have a common ground.
You are trying to use a low-side switch to charge the capacitor,
when a high-side switch is needed. The LED can be low-side
switched, but the LED and its current limiting resistor should
both be in the collector circuit as they together form the load.
Note 0V must be commoned to Arduino ground. The two other wires on the
left are signals from the Arduino (in a circuit diagram signals flow left to right,
power/current flows top to bottom).
The base resistors mean you can use 5V drive from an Arduino pin without
breaking it, the PNP transistor at the top controls charging, and is driven from
one of the NPN's (note again a base resistor to limit current). The optional
resistor from PNP base to emitter helps its be fully turned off.
The other NPN directly switches the LED load.
If all the resistors are 1k it will basically work, though other values might
be better - left as an exercise
wow ok thanks for the help, I'll just ditch my original mess of a circuit then and try that (and look up what low and high-side switching is while i'm at it)
Well, it's good to learn about hardware, but why not use PWM.
2 resistors, one transistor and the LED. And a couple of code lines.
In my Company we use PWM to ramp up current from 15 to 100% with 20 kHz frequency at same time monitoring 3 inputs.
But we use an 4 MHz PIC from microchip.
Is it to fade down an LED? A PWM sequence would do this, as has been suggested.
Things this circuit - using a capacitor - does not do:
Does not save power. You are losing power in the resistors, twice; once to charge the capacitor and once to limit the current to the LED - as you always must do.
Does not make it simple - lots of bias resistors and such.
Does not control the timing - you would have to change capacitors, at best.