How to make a servo stop twitching

I am working on a security system that involves using a servo to pull the trigger on a Nerf gun. This servo is triggered by a laser getting cut which changes the reading on the photo-resistor. It can also be temporarily de-activated by placing by fingerprint on the reader.

The problem is that while the code is not in a delay, the servo twitches back and forth a couple degrees about once a second. This would not be a big deal except for the fact that it makes noise. Is there any way to fix this problem?

Here is a copy of my code:

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Servo.h>

LiquidCrystal lcd(10);

const int RED = 7;
const int GREEN = 6;
const int BLUE = 5;

const int photo = A0;
int light;

int pos = 0;
Servo trigger;
int trig;

SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
int fingerprintID = 0;
int incorrect = 0;

//=========================================================================
void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("  - DH's NERF  ");
  lcd.setCursor(0, 1);
  lcd.print("Security System");
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  trigger.attach(9);
  trigger.write(0);
  trig = 0;
  pinMode(photo, INPUT);
  //greenLED();
  Serial.begin(9600);
  Serial.println("  - DH's NERF Security System");
  finger.begin(57600);
  //delay(1000);
}
//=========================================================================
void loop() {
  fingerprintID = getFingerprintID();
  if (fingerprintID == 1 || fingerprintID == 2) {
    if (trig != 0) {
      trigger.write(0);
      trig = 0;
    }
    Serial.println("  -  Access Granted");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("-Access Granted");
    lcd.setCursor(0, 1);
    lcd.print("Wellcome David!");
    greenLED();
    incorrect = 0;
    delay(4000);
  }
  else if (fingerprintID == -1) {}
  else {
    incorrectFinger();
  }
  if (incorrect >= 3) {
    if (trig != 75) {
      trigger.write(75);
      trig = 75;
    }
    Serial.println("  -  Intruder Recognized");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  < Intruder >  ");
    lcd.setCursor(0, 1);
    lcd.print(" < Recognized > ");
    incorrect = 0;
    redLED();
    delay(4000);
  }
  else {
    runLaserSensor();
  }
}
//=========================================================================
void runLaserSensor() {
  light = analogRead(photo);
  Serial.print(light);
  lcd.setCursor(0, 0);
  lcd.print(light);
  lcd.print("                ");

  if (light <= 333 && light >= 100) { //lots of light
    if (trig != 0) {
      trigger.write(0);
      trig = 0;
    }
    Serial.println("  - Beam is not broken");
    lcd.setCursor(0, 1);
    lcd.print("  - Beam Intact ");
    blueLED();
  }

  else { //not much light
    if (trig != 75) {
      trigger.write(75);
      trig = 75;
    }
    Serial.println("  - Laser Cut!");
    lcd.setCursor(0, 1);
    lcd.print("  - Laser Cut!  ");
    redLED();
  }
  delay(50);
}
//=========================================================================
int getFingerprintID() {
  uint8_t p = finger.getImage(); //take pic of finger
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz(); //look in the figerprint database
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch(); //check if the finger is correct
  if (p != FINGERPRINT_OK) {
    incorrectFinger();
    return -1;
  }
  return finger.fingerID;
}
//=========================================================================
void incorrectFinger() {
  incorrect++;
  Serial.print("Incorrect: ");
  Serial.println(incorrect);
}
//=========================================================================
void greenLED() {
  digitalWrite(RED, LOW);
  digitalWrite(GREEN, HIGH);
  digitalWrite(BLUE, LOW);
}
//==============================================
void blueLED() {
  digitalWrite(RED, LOW);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, HIGH);
}
//==============================================
void redLED() {
  digitalWrite(RED, HIGH);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);
}

Thanks in advance,
--DH

Servo twitching is usually caused by an inadequate servo power supply, like trying to use the Arduino 5V output. Use a separate power supply, like 4xAA batteries, and connect the grounds.

Power is indeed a common problem.
Also, if any of those other libraries use the same timer as Servo.h, you might run in to problems.
A way to get around this is to move the servo signal management off the arduino and on to a driver board.
Adafruit has a 16 channel board for this.

Edit: Here is a link to the Adafruit board.

SoftwareSerial disables interrupts. Can you use only regular Serial?

I am only using the USB hardware Serial. I am also using an external 5 volt power supply that plugs into the wall.

an external 5 volt power supply

For just the servo, with the grounds connected, and capable of providing more than 1 Ampere as required?

That is interesting. I had not realized i still had that in their. Regardless, is there any way to remove that without screwing up this:

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

I just tried running that way with the servo being the only thing pulling power from the 5 volt power supply with and without the grounds connected and it still doesn't work.