To form the concept of an ultrasound sensor, skills and abilities to work with a robotic constructor and EV3 softwareAn ultrasonic sensor (also often called a sonar or ultrasonic rangefinder) determines the distance to an object in the same way as bats or dolphins do.
It is based on the well-known phenomenon of echolocation. The HC-SR04 ultrasonic sensor emits sound pulses (ping) at a frequency of 40 kHz and catches the reflected signal (echo). The HC-SR04 sensor generates a highly directional signal at a frequency of 40 kHz and catches the reflected signal (echo). Based on the time it takes sound to travel to an object and back, you can quite accurately determine the distance to it
2. The purpose
of the lesson
To form the concept of an ultrasound sensor,
skills and abilities to work with a robotic
constructor and EV3 software
3. An ultrasonic sensor (also often called a sonar or
ultrasonic rangefinder) determines the distance to an
object in the same way as bats or dolphins do.
The HC-SR04 sensor generates a highly directional
signal at a frequency of 40 kHz and catches the reflected
signal (echo). Based on the time it takes sound to travel
to an object and back, you can quite accurately
determine the distance to it.
Ultrasonic sensor
Arduino HC-SR04
4. It is based on the well-known phenomenon of echolocation. The HC-SR04 ultrasonic sensor emits
sound pulses (ping) at a frequency of 40 kHz and catches the reflected signal (echo). The range is
determined by the time of transmission of the pulse and its return. That is,
in all of these devices they emit a narrowly directed ultrasonic signal and receive a reflected signal
back.
Operating principle of ultrasonic sensor
5. How the HC-SR04 Ultrasonic Distance Sensor Works?
It emits an ultrasound at 40 000 Hz which travels through the air and if there is an
object or obstacle on its path It will bounce back to the module. Considering the
travel time and the speed of the sound you can calculate the distance.
6. For this lesson you will need:
⮚ ARDUINO UNO
⮚ BREAD BOARD;
⮚ ULTRASONIC HC-SR04;
How to connect an ultrasonic
sensor to Arduino
7.
8. ● Supply voltage 5V;
● Current strength in passive state -6 s.
The ultrasonic rangefinder
HC SR04 has the following technical parameters:
The sensor is equipped with four
terminals :
• Positive type power contact – +5V;
• Trid (T) – input signal output;
• Echo (R) – output signal output;
• GND – “Ground” pin.
9. 1. Get to know the sensor
2. Find out how it works
3. Connecting the sensor to
Arduino
Exercise
10. int trigPin = 8; // assign a name to Pin8
int echoPin = 9; // assign a name to Pin9
void setup() {
Serial.begin(9600); // connect the port monitor
pinMode(trigPin, OUTPUT); // assign trigPin (Pin8) as output
pinMode(echoPin, INPUT); // assign echoPin (Pin9) as input
}
void loop() {
int duration, cm; // assign the variable "cm" and "duration" to the sensor readings
digitalWrite(trigPin, LOW); // initially the sensor does not send a signal
delayMicroseconds(2); // set the delay to 2 mm microseconds
digitalWrite(trigPin, HIGH); // send a signal
delayMicroseconds(10); // set the delay to 10 microseconds
digitalWrite(trigPin, LOW); // turn off the signal
duration = pulseIn(echoPin, HIGH); // enable signal reception
cm = duration / 58; // calculate the distance in centimeters
Serial.print(cm); // display distance in centimeters
Serial.println("cm");
delay(1000); // set a pause of 1 second
}