Simple transistor circuit

raspberry pitheorytransistors

I have been studying transistors and decided to try my knowledge in my lab to find out that nothing works as I thought it would..

I had a small lamp 12V and a handful of 2N3904 transistors, along with a 12V DC power supply.

Attached to the base of the transistor was a pin from my Raspberry Pi, along with a 150 ohm resistor to provide ~20 mA of current. The rest of the transistor was wired as the picture.

enter image description here

However, as soon as I plugged in the power supply, the lamp lit! Even though no current was passing through the base. I tried flipping the transistor around, to see what would happen, as as expected the lamp wouldn't light.

I switched out the lamp with a small solenoid (SparkFun ROB-11015), but now nothing happened while toggling the GPIO pin. I switched out the transistor thinking I fried it, but still nothing… am I missing something?

From what I understand, as long as there is enough current running through the base to saturate the transistor, it should allow current to pass from the power supply to the load. When the transistor is not saturated, the circuit is open.

As an aside, from multimeter readings the GPIO pin is a steady 3.3V and the solenoid draws ~500 mA initially and stabilizes at ~140 mA when wired directly to the power supply.

Best Answer

schematic

simulate this circuit – Schematic created using CircuitLab

I achieved something similar with the below circuit. Does use some extra components, but will happily switch the 12V on and off!

Whilst I think this achieves what you're looking for - i've found it to be better to use a transistor to switch the path to ground on or off, rather than using it to turn the 12V supply on.

See Below;

schematic

simulate this circuit