HC-SR04 SENSOR WITH SNAP4ARDUINO
ULTRASOUND SENSOR
OBJECTIVES
Learn how an ultrasound sensor works
Set Snap4arduino to use this sensor
See the possibilities offered by this sensor in robotic applications
WHAT IS A HC-SR04 ULTRASOUND SENSOR?
The HC-SR04 sensor is a sensor for measuring distances. It is based on sending a non-audible high frequency pulse to the human being. This pulse bounces on nearby objects and is reflected towards the sensor.
By measuring the time between pulses (back and forth), and as we know the speed of sound, we can estimate the distance of the object.
Ultrasonic sensors are cheap and simple to use, but low accuracy sensors. The orientation of the surface to be measured can distort the measurement. These sensors are not suitable in environments with large number of objects because the sound bounces on the surfaces generating echoes and are not suitable for outdoor operation.
The measurement range of the HC-SR04 sensor is from 2 cm to 400 cm, with a resolution of 0.3 cm.
Despite this low accuracy, the sensors are widely used in applications with Arduino to detect obstacles.
ASSEMBLING THE PACTICE
This module, apart from the power pins uses two pins: one to emit the pulse (Trig) and another to receive the rebound of this powder (Echo).
The operation of the HC-SR04 is based on an echo system:
- Send a high digital pulse (10μs minimum) through the TRIG pin.
- Receive the bouncing waves through the ECHO pin.
- Count the time it took to receive the signal.
But all this procedure is built in a snap4arduino bookstore, so fortunately we do not have to worry about making any calculations. To operate the sensor it is necessary to install the Arduino-signed Snap4Arduino-master in our Arduino card and then import the Ultrasound_HC_SR04_blocks file with snap4arduino. Here you can see how the complete process is performed.
The sensor will then connect to Arduino:
- The pin 10 to the TRIG pin.
- Pin 9 to the ECHO pin.
And the code you should
load into Snap4Arduino is as follows:
Now build
this circuit
CODING
When you
have completed the circuit, I propose you two challenges:
- Build an alarm. Each time the sensor detects an object less than 25 cm away, the buzzer must be activated with a flashing beep.
2. Make buzzer
beeps quicker as we move an object closer to the sensor. The further away the
object from the sensor, the beeps the buzzer will emit will be more spaced. When I press space, everything will stop.
MORE IDEAS
TO IN CLASS WITH SNAP4ARDUINO
- Build a mobile radar. On a servomotor mount an ultrasonic sensor HC-SR04.
- To the previous mobile Radar we added a Keyes KY-008 laser module that is mounted on another servomotor will move in the same direction as the radar and fire a laser when the sensor detects an obstacle.
Por favor continua asi, me encantan tus tutoriales
ResponderEliminarMe gustaría saber como se trabaja con un sensor de calor infrarrojo, y añadir que tus tutoriales son muy prácticos e interesantes.
ResponderEliminarBetway app for iOS and Android - JT Hub
ResponderEliminarGet the latest 거제 출장샵 Betway mobile 군산 출장마사지 app, and upgrade to the latest Android version of the popular 제주도 출장샵 Betway casino 통영 출장마사지 app. The mobile version is 서울특별 출장샵 also available for