I've got a circuit I'm building to program a EPROM using an arduino. The schematic I found uses a npn and pnp transistor to switch vpp between 5V and 12V.
Trying to understand why a npn and pnp transistor are both used?
So when pin3 is high, 12V is on vpp. When pin4 is high, 5V on vpp.
I've added the schematic on the right, just using just a npn transistor. Won't it accomplish the same thing?
The single transistor is working in "emitter follower" mode; the emitter will always be no more than 0.7V lower than the base.
With the base running from a 3.3V or 5V logic circuit, the emitter will only rise to 2.6 or 4.3V, not 12V.
That configuration has good current gain, but zero voltage gain.
The two-transistor circuit uses the first transistor to apply base current to the second transistor. The second (PNP, in "common emitter" mode) has it's emitter connected to the +12V supply and it's collector will be able to switch up to very near 12V.
That circuit is not well designed, it should also have a moderate value resistor, eg. 4k7, connected between base and emitter on each of the PNP transistors, to avoid problems with any slight circuit leakage currents.