   pwm.setPWM(left_arm, 0, LEFT_ARM_OPEN);
   delay(500);
 }
+
+void reset_arms()
+{
+  // Sets left_arm and right_arm at their min and max values.
+  pwm.setPWM(left_arm, 0, LEFT_ARM_OPEN);
+  pwm.setPWM(right_arm, 0, RIGHT_ARM_OPEN);
+}
+
+void reset_ears()
+{
+  // Sets left_ear and right_ear at the middle.
+  pwm.setPWM(left_ear, 0, MIDDLE_EAR);
+  pwm.setPWM(right_ear, 0, MIDDLE_EAR);
+}

int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
//            mid C  C#   D    D#   E    F    F#   G    G#   A

void setup()
{
  // Initialize serial port.
  Serial.begin(9600);

  pwm.begin();
  
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  
  // Sets left_arm and right_arm at their min and max values.
  pwm.setPWM(left_arm, 0, LEFT_ARM_OPEN);
  pwm.setPWM(right_arm, 0, RIGHT_ARM_OPEN);
  
  // Sets left_arm and right_arm at their min and max values.
  pwm.setPWM(left_ear, 0, MIDDLE_EAR);
  pwm.setPWM(right_ear, 0, MIDDLE_EAR);
  delay(1000);
}

void loop()
{
  photocellReading = analogRead(photocellPin);
  Serial.print("Analog reading = ");
  Serial.println(photocellReading);     // the raw analog reading
  // invert the reading from 0-1023 back to 1023-0
//  photocellReading = 1023 - photocellReading;
  
  // When kissed or hugged (proximity sensor)
  if ( kissed_flag > 0 )
  {
    wiggle_ears();
    kissed_flag++;
    
    if ( kissed_flag > 4 )
    {
      kissed_flag = 0;
    }
  }
  
  // On button press?
  if ( hug_flag )
  {
    hug();
    hug_flag = 0;
  }
  
  // When it gets bright or dark, make a sound.
  // Stop playing the sound until it's normal lighting out again.
  if ( photocellReading > 800 && photocellReading < 950 )
  {
    normal_light_flag = 1;
  }
  
  if ( photocellReading < 300 && normal_light_flag ) //it is dark
  {
    tone(speakerPin, tones[0]);//play mid C

    noTone(speakerPin);
    normal_light_flag = 0;
  }

  if ( photocellReading > 950 && normal_light_flag ) // it is bright
  {
    tone(speakerPin, tones[9]); //play A
    delay(500);
    noTone(speakerPin);
    normal_light_flag = 0;
  }
  
  // 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 )
  {
    digitalWrite(ledPin, HIGH);
    hug();
    reset_arms();
  }
  else
  {
    digitalWrite(ledPin, LOW);
  }
  
  // check if manually moved
