Let’s see how to create a simple PNP transistor circuit. With this circuit you can use to turn on an LED when it gets dark.
First of all, to turn on the PNP transistor, you need the voltage on the base to be lower than the emitter. For a simple circuit like this, it’s common to connect the emitter to the plus from your power source. This way, you know what voltage you have on the emitter.
When the transistor turns on, the current can flow from the emitter to the collector. So, let’s connect what we want to control: An LED. Since an LED should always have a resistor in series with it, let’s add a resistor too.
You can replace the LED and resistor with whatever you want to control.
To turn on the LED, you need to turn on the transistor so that the channel from emitter to collector opens. To turn on the transistor you need to get the voltage on the base to be 0.7V lower than the emitter, which is 9V – 0.7V = 8.3V.
For example, you can now make the LED turn on when it gets dark by using a photoresistor and a standard resistor set up as a voltage divider.
The voltage on the base won’t behave exactly as the voltage divider formula tells you. This is because the transistor affects the voltage too.
But in general, when the photoresistor value is large (no light present) the voltage will be close to 8.3V and the transistor is on (which turns on the LED). When the value of the photoresistor is low (a lot of light present) the voltage will be close to 9V and turn off the transistor (which turns off the LED).
You might wonder: “How did the photoresistor and resistor on the base magically create the correct voltage of 8.3V when it’s dark?”
It’s partly because the emitter and base makes up a diode. And a diode always try to get its diode voltage over itself. This particular diode has a diode-voltage of about 0.7V. And 8.3V is 0.7V less than 9V.
But, it’s also partly because the size of the photoresistor and resistor on the base sets up the voltage to be in the correct range.