I have HC-SR04 Ultrasonic Sensor with me. I couldn't understand the "Trig" pin's working structure and the working technic. Do we really need it while we use?
(With Arduino examples, I generally use Echo pin more than trig pin.)
image
-
I wonder how you can get anything meaningful from Echo, if you do not use Trig. Are you sure that Trig is not activated by some library you might be using? Or you might have some circuitry driving Trig for you?Igor Stoppa– Igor Stoppa2015年06月14日 10:26:59 +00:00Commented Jun 14, 2015 at 10:26
-
This is a reasonable question, as the Arduino example assumes a 3-pin device where Trigger and Echo are combined, but most suppliers provide a 4-pin one where they are distinct.Chris Stratton– Chris Stratton2015年06月14日 14:46:30 +00:00Commented Jun 14, 2015 at 14:46
3 Answers 3
Yes, you do need it.
The purpose of the TRIG pin is to cause the module to send out a "Ping". It's what makes the whole thing work. As soon as the TRIG pin goes HIGH then LOW (for a period of not less than 10μs) the internal clocks start ticking. 8 cycles of 40KHz audio are sent out of the transmitter and it starts counting how long it takes for the echo to arrive.
If you don't use the TRIG pin the module won't be able to do anything at all.
Two versions of ultrasonic sensors
There are two versions of this device. In the threepin version you trigger the measurement and receive the echo pulse on the same pin. In the four pin version trigger and echo are on separate pins.
Possibly your Arduino example is written for the three pin version.
-
If we can use it with three pins, why do we need it with the four? And Is it meanful with using four pinned one in any project? How? What is the difference?Bay– Bay2015年06月15日 11:31:57 +00:00Commented Jun 15, 2015 at 11:31
-
Two different solutions to the same problem. Both works. You have to interface the version you have. Do you need help with modifying your code?Wirewrap– Wirewrap2015年06月15日 12:14:13 +00:00Commented Jun 15, 2015 at 12:14
-
No, thanks. I learnt how to do. You are kind. Thanks.Bay– Bay2015年06月15日 13:59:47 +00:00Commented Jun 15, 2015 at 13:59
I stumbled across your topic while working in a personal project. As people said earlier, your doubts must be related to the different versions of this board.
Keep in mind that, when using the 4-pin you can keep the ECHO full online as an input, while in the 3-pin version, you need to cancel the ECHO to use it as Output for the TRIG.
This is particularly useful when you need to make a environmental analysis to different responses to different actions.