+21622886281
Arduino HC-SR04

Using the HC-SR04 ultrasonic sensor with Arduino

Purpose of this tutorial:

In this tutorial we will learn how to use a reference ultrasonic distance sensor HC-SR04 with Arduino.

Necessary components

  • Arduino UNO
  • HC-SR04 ultrasonic sensor
  • LCD display
  • connecting wires
  • Test plate

Mounting

For the HC-SR04 sensor we connect:

  • The 3.3V power supply of the Arduino goes to the VCC pin of the sensor.
  • The GND pin of the Arduino goes to the GND pin of the sensor.
  • The digital Pin1 of the Arduino goes to the TRIGGER pin of the sensor.
  • The digital Pin2 of the Arduino goes to the ECHO pin of the sensor.

For the LCD display we connect:

  • the SDA pin at the Arduino analog pin A4.

  • the SCL pin at the Arduino analog pin A5.

  • the VCC pin at the Arduino 5v pin.

  • the GND pin at the Arduino GND pin

Program

Voici le programme  qui permet d’afficher la distance en cm qui sépare Le capteur ultrason d’un obstacle.

Note: you must import the library HCSR04.h for ultrasonic sensor and library LiquidCrystal_I2C.h for the LCD display.

 




0 commentaire


Leave a comment

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Scroll to Top