To connect your HC-SR04 ultrasonic sensor to the Arduino, you only need four cables. Use the following diagram as a reference for the setup:
You’re free to choose which digital pins to use. If you don’t want to modify the sketch in the following lesson, use pins 6 and 7 as shown in the diagram.
Next, we’ll immediately start measuring distances.