1010 LV-MaxSonar-EZ 1

Hi guys! I'm having problem coming up with the code to sense the distance of a particular object from the quadcopter. I have read in the datasheet that the sensor have to wait for 20microseconds before pin 3 which is the analog voltage, can start to read and calculate the value. Can someone please help me? between I am using only analog voltage, no pulse width and this is current my code.

const int anPin = 0; long anVolt, mm, inches;

void setup() { Serial.begin(9600); }

void read_sensor(){ anVolt = analogRead(anPin); mm = anVolt * 5; inches = mm/25.4; }

void print_range(){ Serial.print("S1"); Serial.print("="); Serial.print(mm); Serial.print(" "); Serial.println(inches); }

void loop() { read_sensor(); print_range(); delay(100); }

Please don't cross-post. I've deleted the other topic you'd opened for the same issue.