septillion:
You can but I wouldn'tThe HC-SR04 is pretty low current and it likes a stable voltage. A servo is a beast when it comes to current which will probably make the 5V prone to having spikes and dips. Not a problem for the servo but it is for an IC. And because the HC-SR04 is low current you can connect it to the Arduino 5V which is decoupled from the servo and thus more stable.
TY sir.. hmm.. can u help me code my project?