Can I use a capacitor and a transistor to create a circuit which automatically turns off an LED after a period of time?

So many things wrong with that circuit, lets go back to the start.

The transistor is a valve that lets current flow through it from collector to emitter (the pointy arrow) when current is injected into the base.. as shown below.

As such, as long as you feed current into the base, current will flow through the transistor and, if the voltage on the base is high enough, it will act like a kind of switch.

When turned on, current can flow from the battery through the LED lighting it up. The LED can only withstand so much current or it will burn out. The resistor is included to limit that current to the rated amount specified by the manufacturer's specifications.

schematic

simulate this circuit – Schematic created using CircuitLab

So now you have a circuit that will turn on an LED.

Now you need to drive that circuit with something that turns it on for a while, then turns it off. Now your idea is to do something like this.

schematic

simulate this circuit

Idea being C1 takes a while to charge up through the base limited by the resistor. Indeed with the indicated values the transistor will start to turn off around eight seconds after the power is applied.

Unfortunately a 1mF capacitor is rather physically large and expensive. The resistor choice also affects the current in the LED.

A better solution for this task is to use a different device like an N-Channel MOSFET.

schematic

simulate this circuit

A MOSFET is gated by voltage not current. This effectively decouples the timing side from the driving side. That means you can use much larger resistances, and therefor a smaller capacitor for timing without affecting the LED current.


Let's redraw the schematic. I think you either misunderstood the conventional direction of current or else how the diode is drawn (cathode and anode.) The reason I'm pretty sure you misunderstood something like that is because you otherwise got a reasoned description written out. So let's take your description and redraw the schematic.

Before I do that, there is something else you should immediately work on. And that's learning when to draw wires and when not to. Excess wiring often adds nothing to understanding a circuit, but adds "little black wires going from here to there" that can actually act to confuse rather than improve reading. And there is orientation. You may not understand this point right away, but tuck it away for later. If you just look at a schematic as a picture residing on a big sheet of paper, you want the current flow to go from top (more positive) to bottom (more negative) and you want signal flow to go from left (inputs) to right (outputs.) Broadly speaking, these rules work well to help communicate a schematic better than not following them. (Of course, there are corner cases or idiomatic expressions where the rules probably should be broken. But those are rare.)

schematic

simulate this circuit – Schematic created using CircuitLab

  1. The battery and/or power supply isn't really needed because most of us can simply take note of a node voltage and make the right assumption about the intent. Besides, busing wires around just to show a supply rail and ground line connections is more for people who are wanting to wire up a circuit than for people who want to discuss how a circuit works. Different needs. It's distracting, besides. Though most learn to get past it quickly and get to the meat of the matter, with or without all that, it's still unnecessary.
  2. I've shown \$R_1\$ and \$C_2\$ with currents flowing on the sheet downward. I could have shown them horizontally, too. Whether one wants to look at this leg as being "signal" that should flow left to right, or as a circuit connection where current should flow top to bottom, is a matter of what you want to communicate, I suppose. But here I decided that we are not talking about "signal" but more about initial circuit conditions leading to later circuit conditions. So I show it this way.
  3. Note that I've taken it as granted that you still want to talk about a \$+9\:\textrm{V}\$ supply and that I needed to reverse the arrow directions, as it is the case today that the semiconductor PN junction arrow points from more positive to more negative, when active.
  4. I've used a PNP transistor to remain consistent with the rest.

Assuming the LED, when on, drops about \$2\:\textrm{V}\$ (red), and if the initial conditions for the capacitor are that there are zero volts across it, then, yes... \$R_1\$ will supply base current into the PNP transistor and pull it active. I'd expect a base current of about:

$$I_B\approx \frac{9\:\textrm{V}-2\:\textrm{V}-750\:\textrm{mV}}{3\:\textrm{k}\Omega+\left(\beta+1\right)\cdot 330\:\Omega}$$

If \$\beta\approx 200\$ then this suggests about \$90\:\mu\textrm{A}\$ of base current. Multiplied by \$\beta+1\$ to get the emitter current (in the hopes that the BJT is active and not yet saturated), I get an emitter current of about \$18\:\textrm{mA}\$. This suggests a drop of \$18\:\textrm{mA}\cdot 330\:\Omega\approx 6\:\textrm{V}\$ across \$R_2\$. So this means about \$9\:\textrm{V}-2\:\textrm{V}-6\:\textrm{V}=1\:\textrm{V}\$ on the emitter itself and that means that \$\vert V_{BE}\vert=1\:\textrm{V}\$ and that the BJT is actually still active and not yet saturated. So my assumption is born out and I can apply the \$\beta\$ I assumed earlier.

That is the initial condition. As the capacitor charges up, as you write, it acts to oppose the remaining voltage left available to supply base current (see the above equation and now also subtract the capacitor voltage in the numerator) and the collector current gradually diminishes over time, eventually becoming extinguished when the remaining voltage falls below the ability to keep the BJT active (usefully, when it falls below about \$550-600\:\textrm{mV}\$.)

The time period, or \$\tau\$, will be the value of the capacitor times the associated resistance. In this case, this resistance is "as seen" by the capacitor and it will include both resistors in this way: \$R_2\cdot\left(\beta+1\right)+R_1\$. So with your values and assuming \$\beta=200\$, then \$\tau=1\:\textrm{mF}\cdot\left(\left(\beta+1\right)\cdot R_2+R_1\right)\approx 70\:\textrm{s}\$. Which is pretty darned long.