Sonar Range Finder by Omar and Lucas

Introduction: Sonar Range Finder by Omar and Lucas

This is how you create a sonar range finder using arduino.

First Gather these materials:

  • UNO Arduino board
  • four cables
  • a bread board
  • arduino sonar

Supplies

First Gather these materials:

  • UNO Arduino board
  • four cables
  • a bread board
  • arduino sonar

Step 1: Constructing the Board

first connect the cables to the arduino board to the breadboard so that the cables are connected to specific parts of the sonar, so that 5v to vcc, pin9 to trig pin10 to Echo, Ground to Gnd.

picture from https://randomnerdtutorials.com/complete-guide-for-ultrasonic-sensor-hc-sr04/

Step 2: Coding

Code this

int trigPin = 9;

int echoPin = 10;

float duration;

void setup() { pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

Serial.begin(9600); }

void loop()

{

Serial.begin(9600);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

duration = pulseIn(echoPin, HIGH);

Serial.println(duration);

delay(100); }

Step 3: Testing

place a flat object a specific distance away from the sonar, than record that in to the code so that the code will be able to accurately tell the distance

Be the First to Share

    Recommendations

    • Toys & Games Contest

      Toys & Games Contest
    • Home Decor Challenge

      Home Decor Challenge
    • Arduino Contest

      Arduino Contest

    Comments