DJI Tello Movement Panel icon DJI Tello Movement Panel — Control DJI Tello from ARC with live camera feed for computer vision tracking; fly via scripts, speech, joysticks, Python, or Exosphere. Try it →
Robot Showcase

MEASURING DISTANCE TO OBSTACLE USING THE HC-SR04

2,318 views 0 comments 1 video

About this robot

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

More robots by EzAng

Other projects from the same builder.

Discover more robots

Robots the community built with Synthiam ARC. Get ideas for your next build.


ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.