USING THE HC-SR04 ULTRASONIC SENSOR FOR ECHOLOCATION
in a float in inches
using ARC serial monitor
another video I will use a car
for Arduino
Distance = rate * time
Time = PingTravelTime
Rate = speed of sound - miles per hour - need microseconds
Below
1 second = 1,000,000 micro seconds
I hour = 3600 seconds
Inches to mile
Feet 5280 = 1 mile
12 in = 1 foot
int Trig=A5;
int Echo=A4;
int pingT;
float targ00 secondsetDistance;
void setup() {
// put your setup code here, to run once:
pinMode(Trig,OUTPUT);
pinMode(Echo,INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
targetDistance=measDist();
Serial.println(targetDistance);
delay(500);
}
int pingTime(){
int pingTravelTime;
digitalWrite(Trig, LOW);
delayMicroseconds(2);
digitalWrite(Trig, HIGH);
delayMicroseconds(20);
digitalWrite(Trig, LOW);
pingTravelTime = pulseIn(Echo, HIGH);
return pingTravelTime;
}
float measDist(){
int pingTravelTime;
float Dist;
pingTravelTime=pingTime();
Dist=(pingTravelTime*761.*5280.*12.)/(1000000.*3600.);
Dist=Dist/2;
return Dist;
}
thanks
By EzAng
Other robots from Synthiam community

Cliffordkoperski's F.K.Q. Robot
21dof 19 servos 7.4 volt 2000ma run time 1h servo brackets $70 servos $200 ezbv4 $100 ezb camera $60 cheap as u can get...

Urbanh's Target Bot
So heres the Target Bot. D7 is the main servo. D8 is the switch, which uses the GND and Signal cables (no resistors...

Robotz012248's Project Gizmo Underway!
Thought Id post some pics of Gizmo. Thanks to a great friend that has been helping me Project Gizmo is under way! Im...