I have some solenoid valves that I want to drive from a little beaglebone gpio. The beaglebone is a little ARM based microcontroller.
The gpio on the beaglebone outputs 3v3, and the beablebone itself runs on 5V. The solenoid valves run on 12V. I have some 2n2222a transistors and I thought there was a way to use these to run the 12V devices from the 3v3 GPIO in open collector mode (http://en.wikipedia.org/wiki/Open_collector). What I'm confused about is what this circuit should look like.
I know I need to hook the positive of the 12V supply up to the positive end of the solenoid valve. Then, I think I should hook the negative side of the solenoid valve up to the collector of the transistor. The gpio connects to the base of the transistor via a resistor, enabling me to use the transistor as a switch on the 12V line.
What I don't understand is:
1) Which ground should the emitter of the transistor go to? The one for the beaglebone (which comes off the 5V supply) or the one on the 12V supply?
2) How can I figure out what ohm value of resistor to put between the gpio and the base?
For reference, a datasheet for the 2n2222a can be found here: http://www.csus.edu/indiv/t/tatror/projects/met%20highway%20safety%20project%202010/npn%20transistor.pdf