Instead of 12v it would be 5 from a UBEC, and that same UBEC would also be powering the raspberry pi through the GPIO. Would this work? If so, for the transistor do I use an NPN or PNP? I have a PN2222A. Lastly, how do I find which resistor to use for the base of the transistor.