High side switching from arduino/mcu

To switch devices on/off from logic levels (like the digital outs of an arduino), the easiest way is to put a switch between the device and ground:



But sometimes the ground has to be left connected and you want to turn the device on/off using a switch between the positive supply and the device - so-called 'high-side switching'. One way to do it is shown here, using two transistors (one nmos and one pmos)



The idea is that the mcu logic level turns the nmos on/off, which pulls the gate of the pmos down or lets it float up to the positive supply level (thats why it's connected to the resistor. When the nmos is on the resistance of the nmos is much higher than that of the resistor and hence the resistor 'sees' the positive rail much more, but when the resistance of the nmos is low the gate 'sees' ground. ALternatively you can think of voltage drop over the resistor when there is/isnt current thru the resistor.)

An example with part numbers and values:

Here's a way to do a SPDT switch - only one or the other load is connected to +V. Make sure the maximum Vgs of the right nmos is not exceeded.