 /**
- HC-SR04 Ultrasonic Range Finder attached to the servo.
+ HC-SR04 Ultrasonic Range Finder.
  Two motors attached to the motor shield.
+ speaker/piezo for sound
  */
 
 #include <NewPing.h> // From https://code.google.com/p/arduino-new-ping/
-#include <Servo.h>
+#include <NewTone.h> // From https://code.google.com/p/arduino-new-tone/
 
 // Motor attached to channel A:
 const byte motorA_direction = 12;

    Serial.println("cm");
  }
  
  // Check to see if it's time for another soanr servo move.
  if (millis_now - servo_last > servo_delay) {
    // Remember when this move was done, so we know when to do the next one.
    servo_last = millis_now;
    
    // Sweep
    // Get the last angle the servo was set to.
    int servo_pos = servo.read();
    if (servo_sweep_direction == 0) {
      servo_pos++; // Add 1 degree to the servo's position.
    } else {
      servo_pos--; // Remove 1 degree to the servo's position.
    }
    
    // At the end of the sweep, change directions for the next move.
    if (servo_pos == 170) {
      servo_sweep_direction = 1;
    } else if (servo_pos == 10) {
      servo_sweep_direction = 0;
    }
    servo.write(servo_pos); 
  }
  
}


  digitalWrite(motorB_brake, LOW);   // Disengage the Brake for Channel B
  
  
  // Turn in place constantly.
  digitalWrite(motorA_direction, HIGH); // Channel A forward
  digitalWrite(motorB_direction, LOW); // Channel B backward
  analogWrite(motorA_pwm, 255); // Channel A at max speed 
  analogWrite(motorB_pwm, 255); // Channel B at max speed
  
  playMelody();
}

void loop() {
