HC SR04 not working with DC power supply

Hi, I have modified a demo sketch from "newping" library that do blinking a led when the obstacle is near the sensor. It work great, but when I try to power it trough DC power supply the TX led don't blink and the led doesn't power on. Why? Thanks

What are the specifications of the DC power supply? How is it connected to the Arduino?

The DC power supply is 9v 1000mA, it is connected trough the power jack.

the TX led don't blink .

They won't they are controlled by the PC.

the led doesn't power on.

Suggest something is wrong. Measure the 5V pin and the Vcc pins on the arduino with your multimeter.

If you haven't got a multimeter then why are you doing electronics?

Why measure it vcc is working? With other sketch it work well, so the problem will be software side.

Arduino14: Why measure it vcc is working? With other sketch it work well, so the problem will be software side.

Oh silly me, then your problem is in line 32 of your code.

It work great, but when I try to power it trough DC power supply the TX led don't blink and the led doesn't power on.

It is well known that code knows what power supply it is running from.