Trigger & Echo Wiring
Connect the sensor's two control pins.
Trigger & Echo Wiring is a free Arduino & IoT Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Four Little Pins
The HC-SR04 has four pins in a row: VCC, Trig, Echo, and GND. Get these connected correctly and the sensor just works.
Power It Up
Connect VCC to the Arduino 5V pin. This sensor needs a full 5 volts to charge up and fire its sound pulses properly.
Share a Ground
Wire GND to an Arduino GND pin. Without a shared ground, the signals have no common reference and your readings turn to nonsense.
Trig Is the Speaker
The Trig pin is the sensor's input. When you pulse it HIGH for a moment, the sensor sends out its burst of ultrasonic sound.
Echo Is the Listener
The Echo pin is the sensor's output. It goes HIGH for exactly as long as the sound is travelling out and bouncing back.
Pick Two Digital Pins
Connect Trig and Echo to any two digital pins, for example pin 9 and pin 10. You will name these in code so the Arduino knows where to look.
Name Your Pins
At the top of your sketch, give each pin a clear name. Constants make the rest of your code far easier to read and edit later.
const int trigPin = 9;
const int echoPin = 10;Set the Directions
In setup, declare Trig as OUTPUT so you can drive it, and Echo as INPUT so the Arduino can read the returning pulse.
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);Mind the Echo Voltage
The Echo pin outputs 5V, which a standard Uno reads fine. On a 3.3V board like an ESP32, add a divider so you do not over-volt the pin. ⚠️
Use a Breadboard
Plug the sensor and jumper wires into a breadboard for solid, tidy connections. Loose wires are the top cause of flickering readings.
Double-Check Before Power
Never swap VCC and GND. Before powering on, trace each wire once more so you protect both the sensor and your board.
Quick Check
Think about which pin does what.
Wired and Ready
Power, ground, and two named digital pins, that is the whole hookup. With Trig driving and Echo listening, you are ready to time the pulse. ✅
Frequently asked questions
Is the “Trigger & Echo Wiring” lesson free?
Yes — the full text of “Trigger & Echo Wiring” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “Trigger & Echo Wiring”?
Connect the sensor's two control pins. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Trigger & Echo Wiring” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- How Ultrasonic Ranging Works
- Trigger & Echo Wiring
- pulseIn to Time the Echo
- Build a Proximity Alarm