turning on and off a voltage regulator with a digital output

Hello all. I have an UNO driving 4 servos. The servos are powered with with a 5v voltage regulator. I would like to be able to use a digital out to cut the power to the regulator so the servos dont jitter while idle.

I looked up a data sheet on the 2n7000, which I have laying around, and it appears to only put out 200ma. I'm pretty sure 8050 d128's, which I also have layin around, are no where near the right thing.

I have a relay that will work fine, I'd just rather not use the extra juice off the power supply and I don't think it will physically fit in my setup. I'm pretty sure I need a mosfet, something like this: http://www.radioshack.com/product/index.jsp?productId=13339909&filterName=Type&filterValue=Transistors

Thanks very much!

Depending on what you want to do, 1. as low side switch this transistor are perfekt. 2.As high side switch you need about 10 to 15 volts to the gate. 3. An P-chanel MOSFET together with an PNP smallsignal transistor are easier to use. 4. Change your voltage regulator to an regulator with on/off.


I would like to be able to use a digital out to cut the power to the regulator so the servos don't jitter while idle.

Might be more fruitful to go after the cause of the 'jitter' rather then rather to attack the symptom.

Possible causes:

Need for more filtering of the servo voltage source? Coding problem causing the symptom?

Heres the sketch loaded currently. I think its just refreshing the servos every time thru the loop and causes them to twitch every now and then.

/* attempting to program UNO with ethernet shield to accept commands from a client. 
copied code almost exactly from mouse_test
want to a power transistor to the external voltage regulator to power them up only when a client is connected. this stops the jitter of servos while idle.
PWM pins remaining after ethernetshield are 3, 5, 6, and 9.

#include <Servo.h>
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //mac address of eth shield
IPAddress ip (192,168,1,177); //permanent local IP address
IPAddress gateway (192,168,1,1); //router address
IPAddress subnet (255,255,255,0);
EthernetServer server(80); //using port 80

Servo servoX, servoY, servoA, servoB; //global variables:
int x1, y1, a1, b1;
//const int servoPower = 2;
const int laserPin = 8;
const int buzzerPin = 7;
bool laser = false;
boolean alreadyConnected = false;

void setup() {
  pinMode(laserPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  //pinMode(servoPower, OUTPUT);
  digitalWrite(laserPin, LOW);
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.print("Web server address:");

void loop() {
  a1 = servoA.read(); //gets actual position of servoA/B to send back to processing.
  b1 = servoB.read();
  EthernetClient client = server.available();
  if (client) {
    if (!alreadyConnected){
      alreadyConnected = true;
    while (!client.connected()){
      //digitalWrite(servoPower, LOW); //turns off servos and laser while no client is connected.
      laser = false;
      digitalWrite(laserPin, LOW);
    while (client.connected()){
      //digitalWrite(servoPower, HIGH); //powers on servos.
      static int v = 0;
      if (client.available()>0){
        char ch = client.read();
        switch(ch) { //read incomming characters from processing and handle them case by case.
          case '0'...'9': //0-9 are coordinates.
            v = v *10 + ch - '0';
          case 'x': //signifies end of x coordinate.
            x1 = map(v, 0, 180, 160, 0);
            v = 0;
          case 'y': //end of y coordinate.
            y1 = map(v, 0, 180, 10, 170);
            v = 0;
          case 'l': //turns laser on or off.
            if (laser){
              client.write("1"); //tells processing laser is on.
            else if (!laser){
              client.write("0"); //tells processing laser is off.
          case 'u': //moves servoA up and sends data back to processing to draw a position bar on screen if in range.
            a1 += 2;
            if (a1 >= 150){
              a1 = 150;
            if (a1 < 150){ //if servoA is in range, tell processing to move position bar.
          case 'd':
            a1 -= 2;
            if (a1 <= 20){
              a1 = 20;
            if (a1 > 20){
          case 'a':
            b1 -= 2;
            if (b1 <= 20){
              b1 = 20;
            servoB.write(b1); //same for servoB:
            if (b1 > 20){
          case 's':
            b1 += 2;
            if (b1 >= 160){
              b1 = 160;
            if (b1 < 160){
          case 'b': //fires buzzer while mouse button is held.
            digitalWrite(buzzerPin, HIGH);
          case 'n':
            digitalWrite (buzzerPin, LOW);
    } client.flush();

void laserOnOff(){ //turns laser on/off.
  if (laser == false){
    digitalWrite (laserPin, HIGH);
    laser = true;
  else if (laser == true){
    digitalWrite(laserPin, LOW);
    laser = false;

the PID controller of the servos regulates the angle of the servo when it detects that the servos are not turned in the right angle

my servos often arent aligned with the proper angle they are told to be, and then it makes that noise
try to push them with your finger and see if they stop to jitter when you push them ro right position, maybe this is the cause