Tutorial
Table Of Contents
- 1. Premise
- 2. Raspberry Pi System Installation and Developmen
- 3 Log In to The Raspberry Pi and Install The App
- 4 Assembly and Precautions
- 5 Controlling Robot via WEB App
- 6 Common Problems and Solutions(Q&A)
- 7 Set The Program to Start Automatically
- 8 Remote Operation of Raspberry Pi Via MobaXterm
- 9 How to Control WS2812 RGB LED
- 10 How to Control The Servo
- 11 How to Control DC Motor
- 12 Ultrasonic Module
- 13 Line Tracking
- 14 Make A Police Light or Breathing Light
- 15 Real-Time Video Transmission
- 16 Automatic Obstacle Avoidance
- 17 Why OpenCV Uses Multi-threading to Process Vide
- 18 OpenCV Learn to Use OpenCV
- 19 Using OpenCV to Realize Color Recognition and T
- 20 Machine Line Tracking Based on OpenCV
- 21 Create A WiFi Hotspot on The Raspberry Pi
- 22 Install GUI Dependent Item under Window
- 23 How to Use GUI
- 24 Control The WS2812 LED via GUI
- 25 Real-time Video Transmission Based on OpenCV
- 26 Use OpenCV to Process Video Frames on The PC
- 27 Enable UART
- 28 Control Your AWR with An Android Device
- Conclusion
70
12 Ultrasonic Module
● The camera used by our Raspberry Pi robot is monocular, which cannot collect depth information.
Therefore, many of our robot products use ultrasonic ranging modules to obtain depth information and detect
whether there is an obstacle in a certain direction to obtain the distance of the obstacle.
●The principle of ultrasonic ranging is shown in the following formula:
● S is the distance of the obstacle, T2 is the time when the echo is received, T1 is the time when the
sound wave is emitted, and Vs is the speed of sound propagation in the air. We can use the above formula to
find the distance of the obstacle.
● The model of the ultrasonic ranging module used in our robot products is HC-SR04. The HC-SR04
module has four pins, namely VCC, GND, Echo and Trig. Distance sensing function 2cm-400cm, ranging
accuracy can reach 3mm; module includes ultrasonic transmitter, receiver and control circuit. The basic
working principle is as follows:
· Trigger distance measurement using TRIG of IO port, automatically send 8 40khz square waves to a
high-level signal
·module of at least 10us, and automatically detect whether a signal returns
·When a signal returns, a high level is output through the IO port ECHO. The duration of the high level is
the time from the transmission of the ultrasonic wave to the return.
●When the Motor HAT driver board is used, you need to connect the HC-SR04 to the Ultrasonic interface
on the driver board. You must not connect it to the IIC port to avoid burning the ultrasonic module. (IIC is an
interface used to connect I2C devices, and its VCC and GND pin positions are different from Ultrasonic)
●The method of using Python3 to obtain ultrasonic ranging results is as follows:
import RPi.GPIO as GPIO
import time
Tr = 11 # Pin number of input terminal of ultrasonic module
Ec = 8 # Pin number of output terminal of ultrasonic module