/*******************************************************************************
	Written By: 	Steven Smethurst
	Description: 	Read data from a MaxSonar EZ0 or MaxSonar EZ1  
	
	Version: 
	001 - 08 July 2009 - Created. 

********************************************************************************/

int Look( ) {
	// Take n readings to make sure that the distance is correct. 
	int distsensor = 0;
	int attempts = 100;
	for (int i = 0; i < attempts ; i++) {
		distsensor += analogRead( 1 )  ;
		delay( 10 ); 
	}
	distsensor = distsensor / attempts  ; 
	Serial.println( distsensor );
	return distsensor  ; 		
}

void setup() {
	Serial.begin(9600); // set up Serial library at 9600 bps
	Serial.println("Range finder test.");  
}

void loop() {
	Look( ); 
}

