Arduino Tutorial 55: Measuring Distance With HC-SR04 Ultrasonic Sensor

This lesson builds on the work done in Lessons 53 and 55. In this lesson we use the Ultrasonic Sensor to build a distance sensor. The HC-SR04 ultrasonic sensor can be programmed to send out a ping, and then measure the time it takes to hear the echo of the ping come back, after bouncing off a target. Knowing the speed of sound allows us to calculate distance to the sensor.

The circuit uses the following Schematic:

HC-SR04-Schematic
Schematic for Connecting the HC-SR04 to an Arduino

This is the code we develop in the video

The sensor is part of our Elegoo Kit , so if you get this kit, you will be using the same hardware we are using. This project builds on the work we did in Lesson 53.

For this build we will be using an Arduino Nano, which allows the project to be built on a single breadboard. You can use the Arduino Uno if you do not have a Nano, and things will work out the same. The build neatness is also facilitated by using small straight jumper wires, which you can get HERE.

AI on the Jetson Nano LESSON 32: Tracking an Object with Servos in OpenCV

In this lesson we actively track an object using the Jetson Nano, pan/tilt servos, and OpenCV. In order for this code to work, you need to first set up your servos, as explained in Lesson 31 on youtube. Make sure to follow the instructions on that lesson before trying to do this one, as that will show you how to get your servos connected and set up.

 

Arduino Tutorial 54: Measuring Speed of Sound With HC-SR04 Sensor

HC-SR04
This is our HC-SR04 Ultrasonic Sensor Connected to our Arduino Nano.

In this lesson we explore use of the HC-SR04 sensor to measure the speed of sound. The hookup and programming are pretty simple. The Elegoo Kit includes this sensor, so if you have the kit, you will be using the same hardware we are using. This project builds on the work we did in Lesson 53.

For this build we will be using an Arduino Nano, which allows the project to be built on a single breadboard. This allows cleaner build, and one less likely to have problems from intermittent  connections. The build neatness is also facilitated by using small straight jumper wires, which you can get HERE.

You can connect the sensor up according to this schematic:

HC-SR04-Schematic
Schematic for Connecting the HC-SR04 to an Arduino

The connection pins are the same when connecting to a Nano.

The video below explains how to measure speed of sound from data coming from this sensor.

Code used in Today’s Lesson:

 

Arduino Tutorial 53: Understanding and Connecting the HC-SR04 Sensor

HC-SR04
This is our HC-SR04 Ultrasonic Sensor Connected to our Arduino Nano.

In this lesson we explore using the HC-SR04 from our Arduino Kit to measure distance. The sensor sends out a ping, and then waits to hear the echo. It measures the time between when the ping is sent and when the echo is heard. Knowing pingTravelTime, allows you to calculate distance from the sensor. In this lesson we will show you how to connect the sensor, and program it to read pingTravelTime. In future lessons we will show you how to change this into distance.

Notice we used an Arduino Nano, which allows the entire project to be build on a single breadboard. This allows a neater, smaller build, and one less likely to have problems from poor or loose connections. The build neatness is also facilitated by using small straight jumper wires, which you can get HERE.

Connecting up the HC-SR04 sensor is simple, as illustrated in this diagram:

HC-SR04-Schematic
Schematic for Connecting the HC-SR04 to an Arduino

This video will take you through our build and initial work step-by-step.

The simple code below is what we used in the video to begin making measurements with the sensor.

 

 

Arduino Tutorial 52: Portable Temperature and Humidity Sensor with DHT11

portable temperature sensor
This shows our completed build creating a completely portable DHT11 sensor system

In this lesson we build a completely portable Temperature and Humidity Sensor using the DHT11 sensor. The project is powered by a 9 Volt battery, through the power supply board supplied in the Elegoo Kit.  This project builds on the work we did in Lessons 50 and 51.

Also, notice we used an Arduino Nano, which allows the entire project to be build on a single breadboard. This allows a neater, smaller build, and one less likely to have problems from poor or loose connections. The build neatness is also facilitated by using small straight jumper wires, which you can get HERE.

In the configuration in this project, the regulated power supply is providing power to the Arduino through the 5 Volt pin. In such cases, you should not Also plug the USB cable into the arduino. When powering the Arduino with a regulated power supply, do not connect the USB. If you need to program the arduino, disconnect the external power supply first.

The video below gives a detailed step-by-step description of the project.


The code we developed is presented below: