Combining Servo + LDR, a Button, and a Potentiometer

MBEller99:
Right now I have three separate codes, and I have set up my Arduino Uno and the breadboard to run each one (I just have to upload each code separately). The first code is to control a servo with a photoresistor. The second code is to control a servo with a potentiometer. The third code is to control an LED with a button. My goal is to combine the three so that the servo is controlled by the photoresistor unless I push the button. Then it is controlled by the potentiometer. Most of the code was found online. The LED portion of the third code is not necessary, and the third code needs to be modified to change the control of the servo by a button PRESS (i.e. HIGH to LOW or LOW to HIGH) not just holding the button down. Unfortunately, I am inexperienced with coding, so any help you can give me would be greatly appreciated!

First Code (photoresistor)

#include <Servo.h>

Servo ShutterServo;
const int photoresistor = 1;
const int motor = 12;
int photoresistorValue = 0;
int outputValue = 0;
float nice = 0.09;
float myValue;
void setup() {
Serial.begin(9600);
ShutterServo.attach(motor);
}
void loop() {
photoresistorValue = analogRead(photoresistor);
myValue = float(map(photoresistorValue, 0, 100, 0, 180));
outputValue += int(myValue - outputValue) *nice;
Serial.print("sensor = ");
Serial.print(photoresistorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
ShutterServo.write(outputValue);
delay (10);
}




**Code Two (potentiometer)**


#include <Servo.h>
Servo ShutterServo;
int potpin = 0; 
int val;
void setup()
{
ShutterServo.attach(12);   
}
void loop()
{
  val = analogRead(potpin);           
  val = map(val, 0, 1023, 0, 179);     
  ShutterServo.write(val);                 
  delay(15);                         
}




**Code Three (button)**


const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:   
    digitalWrite(ledPin, HIGH); 
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}