Arduion Nano (ATmega168) and SRF08 Ext. Power Prob

Ok… here’s my problem. My project works perfectly when it is powered by the USB. When I unplug the USB and power it externally, the project works perfectly until I get something very close to the range finder. At this point, it does sense something close to the range finder but it seems to get locked into thinking something is close to the range finder until I remove power. After the project is re-started with power it works again just fine until something gets too close… then it stays stuck thinking something is close until I remove power, then add power again. I think this is a software problem, rather than hardware… though I could be wrong. I am very new at this… I found some code on the net and modified it to work for my purposes. Any suggestions/help?

#include <Wire.h>

#define rxPin 2 // Software serial pin for rx
#define srfAddress 0x70 // Address of the SRF08
#define cmdByte 0x00 // Command byte
#define lightByte 0x01 // Byte to read light sensor
#define rangeByte 0x02 // Byte for start of ranging data

int vpin = 13; //output digital pin number

byte highByte = 0x00; // Stores high byte from ranging
byte lowByte = 0x00; // Stored low byte from ranging

byte sensorPin=0;
int latestVal=0;
int maxVal=0;
int minVal=1024;

void setup(){

delay(100); // Waits to make sure everything is powered up before sending or receiving data
Serial.begin(9600); //Readys Serial Port for Transmission (USB)
pinMode(rxPin, INPUT);
pinMode(vpin, OUTPUT);

void loop(){
int rangeData = getRange(); // Calls a function to get range
Serial.println(rangeData); //Sends SRF found range to Serial port (USB)

digitalWrite(vpin, HIGH); // sets the LED on
delay(100); // output signal time length
digitalWrite(vpin, LOW); // sets the LED on
delay(rangeData * 10); // waits 10 MS FOR EVERY CM

int getRange(){ // This function gets a ranging from the SRF08

int range = 0;

Wire.beginTransmission(srfAddress); // Start communticating with SRF08
Wire.send(cmdByte); // Send Command Byte
Wire.send(0x51); // Send 0x51 to start a ranging

delay(100); // Wait for ranging to be complete

Wire.beginTransmission(srfAddress); // start communicating with SRFmodule
Wire.send(rangeByte); // Call the register for start of ranging data

Wire.requestFrom(srfAddress, 2); // Request 2 bytes from SRF module
while(Wire.available() < 2); // Wait for data to arrive
highByte = Wire.receive(); // Get high byte
lowByte = Wire.receive(); // Get low byte

range = (highByte << 8) + lowByte; // Put them together

return(range); // Returns Range