Interfacing 2 HC-SR04 to PIC Microcontroller – electroSome https://electrosome.com/topic/two-hc-sr04-pic-microcontroller/feed/ Sat, 18 Mar 2023 04:53:32 +0000 https://bbpress.org/?v=2.6.9 en-US https://electrosome.com/topic/two-hc-sr04-pic-microcontroller/#post-13461 <![CDATA[Interfacing 2 HC-SR04 to PIC Microcontroller]]> https://electrosome.com/topic/two-hc-sr04-pic-microcontroller/#post-13461 Thu, 02 Feb 2017 13:38:06 +0000 charmi pabari How can I interface two HC-SR04 ultrasonic distance sensor with PIC 16F877A using a single timer (timer 1) ?

]]>
https://electrosome.com/topic/two-hc-sr04-pic-microcontroller/#post-13467 <![CDATA[Reply To: Interfacing 2 HC-SR04 to PIC Microcontroller]]> https://electrosome.com/topic/two-hc-sr04-pic-microcontroller/#post-13467 Fri, 03 Feb 2017 07:36:14 +0000 Ligo George You can do that. Just need to read one by one. See below.

  1. Send trigger to first HC-SR04
  2. Start timer
  3. Listen for echo.
  4. Stop timer once you got the echo
  5. Convert timer value to distance (first distance)
  6. Send trigger to second HC-SR04
  7. Start timer
  8. Listen for echo
  9. Stop timer once you got the echo
  10. Convert timer value to distance (second distance)

So it is easy. A microcontroller can do above steps very fastly, so it will appear to you that both sensors are reading simultaneously.

]]>