ARDUINO - DISTANCE METER WITH ULTRASONIC HC-SR 04

1,515

19

1

Published

Introduction: ARDUINO - DISTANCE METER WITH ULTRASONIC HC-SR 04

Hallo, my name is Rizky Ananda, here I would like to tell my little knowledge whom I get from my collage namely how to make a distance meter with ARDUINO . This is a simple project but I hope it is useful for all of you.

This project could you use for helping your daily activity, especially for measuring something or anything else that is useful from this project.

Here I would like to show Ultrasonic, LCD, and Potensiometer that are joined and operated by ARDUINO.

Step 1: Assemble Materials

Arduino Uno

Breadboard

HC-SRO4 Ultrasonic Sensor

LCD

Potensio Meter

Jumper Wires

Step 2: Connections

Please follow the step such as the image

This image shows a ultrasonic component is connected with arduino :

  • Trigpin is connected to Arduino 11 contact
  • Echopin is connected to Arduino 10 contact
  • VCC is connected to 5v contact, and
  • Grnd is connected to GND contact on Arduino

Step 3: Code

#define ECHOPIN 10

#define TRIGPIN 11

#include

LiquidCrystal lcd(2,3,4,5,6,7);

int H2,HT,H1;


void setup() {

lcd.begin(16,2);

lcd.print("Distancemeter");

lcd.setCursor(0,1);

lcd.print("Distance= ");

pinMode(ECHOPIN, INPUT);

pinMode(TRIGPIN, OUTPUT);

delay(100);

HT=200;

}

void loop() {

digitalWrite(TRIGPIN,LOW);

delayMicroseconds(2);

digitalWrite(TRIGPIN,HIGH);

delayMicroseconds(10);

digitalWrite(TRIGPIN,LOW);

int distance = pulseIn(ECHOPIN,HIGH);

distance = distance/29.41/2;

H2=HT-distance;

lcd.setCursor(9,1);

lcd.print(200-H2);

lcd.print("cm");

delay(100);

}

Step 4: FINISH - the Working Arduino

THANKS

Share

    Recommendations

    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest
    • Water Contest

      Water Contest

    Discussions

    Welcome to Instructables! Thanks for sharing :)