     }
     
     reset_ears();
-    normal_light_flag = 0;
-  }
-  
-  button_state = digitalRead(button_pin);
-  
-  if ( button_state == HIGH )
-  {
-    hug();
-    reset_arms();
   }
   
   // TODO: check if manually moved
+  // is this as simple as just resetting the ears and arms after every loop?
+  // This would work, I think, but could also draw a lot more power than otherwise.
+}
+
+uint16_t readProximity() {
+  write8(VCNL4000_COMMAND, VCNL4000_MEASUREPROXIMITY);
+  while (1) {
+    uint8_t result = read8(VCNL4000_COMMAND);
+    //Serial.print("Ready = 0x"); Serial.println(result, HEX);
+    if (result & VCNL4000_PROXIMITYREADY) {
+      return read16(VCNL4000_PROXIMITYDATA);
+    }
+    delay(1);
+  }
+}
+
+// Read 1 byte from the VCNL4000 at 'address'
+uint8_t read8(uint8_t address)
+{
+  uint8_t data;
+
+  Wire.beginTransmission(VCNL4000_ADDRESS);
+#if ARDUINO >= 100
+  Wire.write(address);
+#else
+  Wire.send(address);
+#endif
+  Wire.endTransmission();
+
+  delayMicroseconds(170);  // delay required
+
+  Wire.requestFrom(VCNL4000_ADDRESS, 1);
+  while(!Wire.available());
+
+#if ARDUINO >= 100
+  return Wire.read();
+#else
+  return Wire.receive();
+#endif
+}
+
+
+// Read 2 bytes from the VCNL4000 at 'address'
+uint16_t read16(uint8_t address)
+{
+  uint16_t data;
+
+  Wire.beginTransmission(VCNL4000_ADDRESS);
+#if ARDUINO >= 100
+  Wire.write(address);
+#else
+  Wire.send(address);
+#endif
+  Wire.endTransmission();
+
+  Wire.requestFrom(VCNL4000_ADDRESS, 2);
+  while(!Wire.available());
+#if ARDUINO >= 100
+  data = Wire.read();
+  data <<= 8;
+  while(!Wire.available());
+  data |= Wire.read();
+#else
+  data = Wire.receive();
+  data <<= 8;
+  while(!Wire.available());
+  data |= Wire.receive();
+#endif
+  
+  return data;
+}
+
+// write 1 byte
+void write8(uint8_t address, uint8_t data)
+{
+  Wire.beginTransmission(VCNL4000_ADDRESS);
+#if ARDUINO >= 100
+  Wire.write(address);
+  Wire.write(data);  
+#else
+  Wire.send(address);
+  Wire.send(data);  
+#endif
+  Wire.endTransmission();
 }
 
 void wiggle_ears()

  photocell_reading = analogRead(photocell_pin);
  Serial.print("Analog reading = ");
  Serial.print(photocell_reading);
  // Commented out because it's unneeded debugging information.
  // Serial.print(", ");
  // Serial.println(normal_light_flag);

  // When it gets bright or dark, make a sound.
  // Stop playing the sound until it's normal lighting out again.
  if ( photocell_reading >= 700 && photocell_reading <= 710 )
  {
    normal_light_flag = 1;
  }

  if ( photocell_reading < 700 && normal_light_flag )
  {
    play_song(0);
    normal_light_flag = 0;
  }
  else if ( photocell_reading > 710 && normal_light_flag )
  {
    for ( int i = 0; i < 4; i++ )
    {

#include <Adafruit_PWMServoDriver.h>
#include <Wire.h>
#include "pitches.h"

// **************************
// **** PROXIMITY SENSOR ****
// **************************
// i2c address
#define VCNL4000_ADDRESS 0x13

// commands and constants
#define VCNL4000_COMMAND 0x80
#define VCNL4000_PRODUCTID 0x81
#define VCNL4000_IRLED 0x83
#define VCNL4000_AMBIENTPARAMETER 0x84
#define VCNL4000_AMBIENTDATA 0x85
#define VCNL4000_PROXIMITYDATA 0x87
#define VCNL4000_SIGNALFREQ 0x89
#define VCNL4000_PROXIMITYADJUST 0x8A

#define VCNL4000_3M125 0
#define VCNL4000_1M5625 1
#define VCNL4000_781K25 2
#define VCNL4000_390K625 3

#define VCNL4000_MEASUREAMBIENT 0x10
#define VCNL4000_MEASUREPROXIMITY 0x08
#define VCNL4000_AMBIENTREADY 0x40
#define VCNL4000_PROXIMITYREADY 0x20

uint16_t ambient_reading = 0;
uint16_t proximity_reading = 0;

// **********************
// **** SERVO SHIELD ****
// **********************
// Uses the default address 0x40.
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

// These are the minimum and maximum pulse length counts (out of 4096).
#define BIG_SERVO_MIN 160
#define BIG_SERVO_MAX 584
#define MICRO_SERVO_MIN 160
